Invoke-UAScript with -Credential

Invoke-PSUScript -Script $Script -Credential (Get-UAVariable -name 'User1')

The code above is working correctly for me. I needed to allow the script being invoked to run and understand that $User continues to evaluate to the service account, but everything in the script is in fact executing with the credentials specified in the (Get-UAVariable -name ‘User1’) variable. This was confirmed by storing the current user with “whoami”.

1 Like