Skip to content

Instantly share code, notes, and snippets.

@midacts
Last active April 17, 2017 00:27
Show Gist options
  • Save midacts/3f6f3304dcfad54765f8faa11ecb05d8 to your computer and use it in GitHub Desktop.
Save midacts/3f6f3304dcfad54765f8faa11ecb05d8 to your computer and use it in GitHub Desktop.
Checking $Desired when it is $null - ran into
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