Product: PowerShell Universal
Version: 3.4.1
When I run a job via the “Scripts” are of PSU my job runs fine. It matches on the IF statement and exits as it should. When I run the Script via the Scheduler it does NOT match the IF condition. I tried logging into my Windows 2016 server and running the script as myself and the service account user tied to PSU. When I debug both match true and have the same data in the variables.
[string]$netboxCompletedTagName = "ap-mgmgt-subnet-converted"
# Looks up the store's site in NetBox and returns the object
# Will throw an error if it receives more or less than 1
$netboxStore = Get-DSGNetboxSiteByStoreNumber -store_number $storenumber
if ($netboxStore.count -ne 1){write-error "netboxStore did not return 1 object"}
[array]$siteTags = $netboxStore.results.tags.slug
# Exits the script if -netboxCompletedTagName is found on the site object in NetBox
if ( $netboxCompletedTagName -in $siteTags) {
Write-Warning "$($netboxCompletedTagName) NetBox Site tag found on NB store $($netboxStore.results.name)... exiting"
Write-host $siteTags
return
}
else {
Write-Output 'hit else statement in ( $netboxCompletedTagName -in [array]$netboxStore.results.tags.slug)'
Write-Output $siteTags
return
}