Invoke-SqlCmd2
Invoke-SqlCmd2 copied to clipboard
Slowness on import caused by first line of Invoke-SqlCmd2.ps1
per @FriedrichWeinmann : Measure-Command { Get-Item function:\Invoke-Sqlcmd2 -ErrorAction Ignore }
Strange! I can't seem to replicate this. It could be related to this, and I've seen AV add to this.
Any chance you could swap in Bartek's method for loading functions into the psm1 to see if this resolves the issue? Otherwise, I'm happy to just make the change (PR in dbatools dev branch, pull back here?)
On that note / aside, I'll open another issue on a process for automating that, if it makes sense:
- dbatools appveyor job runs
- tests run, if they pass...
- clone this repo
- replace invoke-sqlcmd.ps1, git add, git commit (re-use commit message from dbatools push), git push
SSH key or some other auth can be stored in AppVeyor secure variables, if you're comfortable with that. Or... AppVeyor might already be running with that permission? Not sure!
Cheers!
Hi Warren, we already use that method of loading files. This delay on Get-Command happens, when the command isn't available only. Cheers, Fred
Gotcha - I left in some cruft that might be slowing things down - removing the bit that searches a non-existent private folder cuts down the speed for me from 800ms to 100ms or so.
Still can't duplicate a two second delay though, could something else be in play on your system (anti-malware software, for example)?
Hey Warren, Not sure about the dela -- I use the default Microsoft malware stuff.
The appveyor thing sounds good :) Right now, I'm just putting it in the manual publish.ps1 that I have LOL.
Lemme know when that cruft has been removed (or where I can remove it) -- I'd love to include the speed up in the upcoming release.