@adam , for testing, I have manually given my accounts the rights needed as outlined in https://docs.powershelluniversal.com/config/running-as-a-service-account
With that being said, my script is executing successfully, but not executed as the end user. I’m using the code below but $env:USERNAME inside of the script being invoked is the account running the Windows Service instead of the user account. The job description makes it appear that it executed successfully "run manually by serviceAccountName in the 7.1.3 environment as User1. However the output shows it executed as the service Account.
Invoke-PSUScript -Script $Script -Credential (Get-UAVariable -name 'User1')
Update: $env:USERNAME is still evaluating to the service account, however “whoami” is evaluating to the user… the main focus is figuring out how to pass the PSCredential object into the script so that I can create PSSessions with the user’s account.
I’ve attempted to pass the PSCredentials as follows but it does not appear to be passing them to the script file successfully: