Hi All,
Greetings !!!
I'm using PowerShell Studio 2012 to create one tool to perform different administrative tasks. I do not want to run the output tool.exe as an administrator. I want to run that as 'Run As Different User' and provide credentials at that time. Also, I want to use those credentials further in my script to perform several tasks on remote computers without providing them again and again during run-time.
Can you please help to suggest a method to do that ?
Thanks...
How to use 'Run As Specified User' credentials in my script further ?
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Re: How to use 'Run As Specified User' credentials in my script further ?
You can't. You can re-launch your script using credentials
$cred=Get-Credential
start-process -FilePath powershell -ArgumentList "c:\temp\myscrip.ps1" -Credential $cred
$cred=Get-Credential
start-process -FilePath powershell -ArgumentList "c:\temp\myscrip.ps1" -Credential $cred
Re: How to use 'Run As Specified User' credentials in my script further ?
Do you know how and where PowerShell Studio keeps my credentials when I launch EXE with 'Run As Different User' ?
I'm asking because I'm able to do some task written in script with those provided credential as cmdlets don't require them For e.g. Get-Service
But, if I need to run a command to remove app-v package on remote machine, it requires credentials if used with Invoke-Command.
Invoke-Command -ComputerName $c -ScriptBlock {Remove-AppvClientPackage -Name XXX} -Credential $cred
I want to use $cred as what I provided to run my EXE.
I'm asking because I'm able to do some task written in script with those provided credential as cmdlets don't require them For e.g. Get-Service
But, if I need to run a command to remove app-v package on remote machine, it requires credentials if used with Invoke-Command.
Invoke-Command -ComputerName $c -ScriptBlock {Remove-AppvClientPackage -Name XXX} -Credential $cred
I want to use $cred as what I provided to run my EXE.
Re: How to use 'Run As Specified User' credentials in my script further ?
$cred is not stored anywhere.
When you use RunAs the credentials are stored in the password vault. Unfortunately it requires elevation to retrieve the password.
When you use RunAs the credentials are stored in the password vault. Unfortunately it requires elevation to retrieve the password.