The problem is that both of the SID variables are created from a varbinary column in SQL Server so are byte arrays. –notmatch doesn’t work as presumably expected in that case as shown below.
[byte[]] $CurrentUserSid = 1,2,3
[byte[]] $JobScheduleOwnerSid = 1,2,3
Clear-Host
if ($CurrentUserSid -notmatch $JobScheduleOwnerSid)
{
Write-Host "Not owner of the schedule - current method"
}
This will need to be changed to something like….
if(@(Compare-Object $CurrentUserSid $JobScheduleOwnerSid -SyncWindow 0).Length -gt 0)
{
Write-Host "Not owner of the schedule - alternate method"
}
This path is only hit when the job has an existing schedule whose name does not exist in the job XML so probably not that common an occurrence.
The problem is that both of the SID variables are created from a varbinary column in SQL Server so are byte arrays. –notmatch doesn’t work as presumably expected in that case as shown below.
This will need to be changed to something like….
This path is only hit when the job has an existing schedule whose name does not exist in the job XML so probably not that common an occurrence.