dataplat / Invoke-SqlCmd2

PowerShell module containing Invoke-SqlCmd2
MIT License
68 stars 35 forks source link

Added guard clauses for Set-StrictMode -Version Latest #14

Closed AndyP2 closed 5 years ago

AndyP2 commented 6 years ago

Added guard clauses for $ApplicationName and $PSBoundParameters.Verbose, so missing values don't cause problems when running with Set-StrictMode -Version Latest.

Without them I get these error messages: The variable '$ApplicationName' cannot be retrieved because it has not been set. at Invoke-Sqlcmd2.ps1: line 386 The property 'Verbose' cannot be found on this object. Verify that the property exists. at Invoke-Sqlcmd2.ps1: line 467

To be honest my preference would be for $ApplicationName to be passed in as an optional parameter, but I don't know what the original Invoke-SqlCmd does here.

potatoqualitee commented 5 years ago

So sorry, this has a conflict and there was no follow up response to cookie's message. Please feel free to resync and resubmit.

AndyP2 commented 5 years ago

That's not a problem, I have a version that works for my project anyway. The changes requested were much larger than the quick bug fix I submitted, so if anyone wants to add support for strict mode I'm happy for them to do it themselves.

AndyP2 commented 5 years ago

I've had problems with verbosepreference values in modules in the past, and it would only solve one of the problems anyway.