I have a PowerShell script, called by a Kaseya script, that needs to be run as the user specified in Set Credential. (It does some looking through directories and so it needs to have the appropriate credentials to read to the NTFS folders.) I'm kind of stuck because while the script runs and behaves as expected, but it doesn't work because it's not running as the correct user. It should run as the Administrator (which is what was set under Set Credential), but instead it runs as the user that the Kaseya Agent runs as. I can run the script directly on the machine as the correct user and it does work. So, I added a "Use Credential" to my Kaseya script, but a whoami run by the PowerShell script reports (NT Authority\System) which is the user that the Kaseya Agent runs as. Am I missing something obvious, is there a trick to Use Credential, or is this a bug? I've put in a support ticket, but hoping maybe someone else has encountered this and knows the answer?
Check the "Execute as" option, you would want to use the "Execute as the logged on user" option with the "Use Credential. Your Agent Credentials should be either a local admin or a domain admin that has local permissions. Also there is an "Impersonate user" option that you could try.
Thanks, HardKnoX - I was setting Use as System account in the script. It's working properly when I set it as Execute as the Logged on user. I didn't think that one through. Appreciate the help!