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.