You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the above example, $wrongVariable doesn't exist, and $sqlJob ends up with ALL SQL JOBS in it, which are then deleted.
(Confirmation was skipped because this is meant to run without human interaction.)
I would expect the cmdlet to NOT proceed if there is a null value passed to a parameter.
The parameter is not MANDATORY, but if it's being explicitly passed, then it should contain something.
I don't know how much of this is Powershell's default behaviour VS a conscious design decision on the dbatools Cmdlets.
The text was updated successfully, but these errors were encountered:
Summarize Functionality
Passing null values to parameters will result in errors instead of the cmdlets proceeding as if the parameter was not explicitly passed.
Is there a command that is similiar or close to what you are looking for?
Yes
Technical Details
Not sure whether to report this as a bug or feature request, but here it goes.
I've just had a fun incident where I deleted all SQL jobs on an instance because I passed a variable name which didn't exist:
In the above example, $wrongVariable doesn't exist, and $sqlJob ends up with ALL SQL JOBS in it, which are then deleted.
(Confirmation was skipped because this is meant to run without human interaction.)
The same happens if I run the command like this:
$sqlJob = Get-DbaAgentJob -SqlInstance $sqlServer -Job ""
$sqlJob = Get-DbaAgentJob -SqlInstance $sqlServer -Job $null
I would expect the cmdlet to NOT proceed if there is a null value passed to a parameter.
The parameter is not MANDATORY, but if it's being explicitly passed, then it should contain something.
I don't know how much of this is Powershell's default behaviour VS a conscious design decision on the dbatools Cmdlets.
The text was updated successfully, but these errors were encountered: