Powershell script: Code for running the ps1 file as admin

We are checking if the current ps1 file is opened in an admin mode. If it is not running in the admin mode, we are trying to open the powershell file .ps1 in the admin mode with the following code:

  $process=Start-Process  $psHome\powershell.exe -Verb Runas -ArgumentList $arg -wait -Passthru

We are getting below error:

Start-Process : This command cannot be run due to the error: This operation requires an interactive window station.

August 28th, 2015 12:05am

You cannot run that unattended.  It must be run by a person and not as a task or remote script.

Free Windows Admin Tool Kit Click here and download it now
August 28th, 2015 12:21am

What is the value of $arg ?
August 28th, 2015 4:58pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics