Last active
April 17, 2017 00:27
-
-
Save midacts/3f6f3304dcfad54765f8faa11ecb05d8 to your computer and use it in GitHub Desktop.
Checking $Desired when it is $null - ran into
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
It -Name "$Scope $($Object.Name) - $Title" -Test { | |
Try { | |
# Pump the brakes if the config value is $null | |
If ($Desired -eq $NULL) | |
{ | |
Write-Verbose "Verifying `$Desired` is still `$NULL" | |
($Desired -eq (& $Actual -as $Type)) -or ("" -eq (& $Actual -as $Type)) | Should Be $True | |
} | |
Else | |
{ | |
# "& $Actual" is running the first script block to compare to $Desired | |
# The comparison should be empty | |
# (meaning everything is the same, as expected) | |
Compare-Object -ReferenceObject $Desired -DifferenceObject (& $Actual -as $Type) | Should BeNullOrEmpty | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment