- 1 year ago
Run script on Windows Container as administrator
To run a script as an administrator on a Windows Container, you can use the Start-Process
cmdlet with the -Verb RunAs
parameter. This allows you to launch a script with elevated privileges. Here's an example:
powershellStart-Process powershell.exe -ArgumentList "-ExecutionPolicy Bypass -File C:\path\to\script.ps1" -Verb RunAs
In the example above, replace C:\path\to\script.ps1
with the actual path to your script.
This command starts a new PowerShell process with the -ExecutionPolicy Bypass
argument to bypass any script execution policies that might be in place. The -File
parameter specifies the path to the script you want to run.
By using the -Verb RunAs
parameter, the PowerShell process is launched with elevated administrator privileges.
Note that running a script with administrator privileges can have security implications. Ensure that you trust the script and understand the potential consequences before executing it as an administrator.