Support Forums

How to use 'Run As Specified User' credentials in my script further ?

Ask your Windows PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.
User avatar
ashish44s
Posts: 17
Joined: Thu Feb 11, 2016 10:06 am

How to use 'Run As Specified User' credentials in my script further ?

Postby ashish44s » Thu Feb 11, 2016 10:16 am

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...
User avatar
jvierra
Posts: 10017
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: How to use 'Run As Specified User' credentials in my script further ?

Postby jvierra » Thu Feb 11, 2016 12:47 pm

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
User avatar
ashish44s
Posts: 17
Joined: Thu Feb 11, 2016 10:06 am

Re: How to use 'Run As Specified User' credentials in my script further ?

Postby ashish44s » Thu Feb 11, 2016 2:58 pm

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.
User avatar
jvierra
Posts: 10017
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: How to use 'Run As Specified User' credentials in my script further ?

Postby jvierra » Thu Feb 11, 2016 5:19 pm

$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.

Return to “Windows PowerShell”

Who is online

Users browsing this forum: No registered users and 1 guest