locked
Run Powershell Script as admin server 2012 RRS feed

  • Question

  • Hi

    How can i start a Powershell script from cmd as admin on Server 2012.

    Thursday, August 15, 2013 12:43 PM

Answers

  • Hi,

    Start-Process "$psHome\powershell.exe" -Verb Runas -ArgumentList '-command "Get-Service"'

    This would run "Get-Service" as administrator.

    Regards,

    Yan LI


    Cataleya Li
    TechNet Community Support

    • Marked as answer by Yan Li_ Thursday, August 22, 2013 12:25 PM
    Friday, August 16, 2013 8:19 AM

All replies

  • Right mouse click the command prompt and select "Run as administrator" or use the runas command.


    TechNet/MSDN Forum Moderator - http://www.leedesmond.com

    • Proposed as answer by Yan Li_ Friday, August 16, 2013 8:12 AM
    Thursday, August 15, 2013 12:46 PM
  • its run from a program called autosys there remote starts a cmd  so i can not right click i need a cmd command to start powershell as admin
    Thursday, August 15, 2013 1:13 PM
  • You might be able to use Bill Stewart's elevation toolkit as an intermediary to help you with this:

    http://www.westmesatech.com/misctools.html


    Don't retire TechNet!

    Thursday, August 15, 2013 2:11 PM
  • Hi,

    Start-Process "$psHome\powershell.exe" -Verb Runas -ArgumentList '-command "Get-Service"'

    This would run "Get-Service" as administrator.

    Regards,

    Yan LI


    Cataleya Li
    TechNet Community Support

    • Marked as answer by Yan Li_ Thursday, August 22, 2013 12:25 PM
    Friday, August 16, 2013 8:19 AM