Quantcast
Channel: VMware Communities : All Content - vRealize Automation Tools
Viewing all articles
Browse latest Browse all 9859

howto run script block as different user?

$
0
0

Hi,

within a software component I need to run a setup.exe as a service account.

For some reason I get a "access denied" error whatever I try.

So I simplified it to avoid other factors and just try to run a "whoami | out-file c:\temp\who.log" as a different users. Still failing.

 

what I do:

$securePassword = ConvertTo-SecureString $Password -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential "$domain\$account", $securePassword

start-job -ScriptBlock {whoami | out-file c:\temp\who.log} -Credential $credential | wait-job

 

I also tried start-process ..... -credential ....

with same result.

 

UAC is disabled via registry.

 

Any help would be highly appreciated.

 

Thanks

Andre


Viewing all articles
Browse latest Browse all 9859

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>