Can I get some help with a PowerShell if statement? I'm looking to write something like If the script/custom command is fired via a scheduled task do this. If/Else the script/custom command is fired manually against a user do this.
I was thinking I could do something like this but I'm getting an error that TaskName property cannot be found in the cache when running the custom command against a user.
if ($Context.Initiator.UserAdsObject.Get("TaskName") -eq "My Scheduled Task") {"Do Something"} Else {Do Something Different"}
Thanks!
Ryan