none
How to Pass password to Run as a Network Account in powershell RRS feed

  • Question

  • Hello,

    I ve been asked to raise this as a new topic as given in the link. The response also says that it is not possible to pass the password of a network account in powershell. How else can I implement the requirement?

    http://social.technet.microsoft.com/Forums/windowsserver/en-US/41a4ba3d-93fd-485b-be22-c877afff1bd8/how-to-run-a-powershell-script-in-admin-account?forum=ITCG&prof=required

    My requirement is that, I am need to run the powershell script via a network account. The powershell is called via a script on an ETL tool. When I ask it to print the output of the below command, the output says " Enter the password of domain\username:". 

    PS > runas /user:{domain}\{username} powershell -file {nameOfPowershellScript.ps1}

    Hence I had to modify the code to pass the password also in the same command. I am new to powershell scripting and the below command doesn't work. Please suggest the appropriate way to pass the password of the network account.

     Referred to a link http://technet.microsoft.com/en-us/magazine/ff714574.aspx. 

    $password = Get-Content c:\temp\password.txt | ConvertTo-SecureString 

    $credential = New-Object System.Management.Automation.PSCredential "CachedUser",$password 

    PS > runas /user:{domain}\{username} powershell -file {nameOfPowershellScript.ps1}

    PS >$credential.Password | ConvertFrom-SecureString | Set-Content c:\temp\password.txt 


    • Edited by Shweth Friday, March 14, 2014 3:00 PM Refered link provided
    Wednesday, March 12, 2014 9:56 AM