This PS1 File
(test.ps1
), while executed, will run The Commands Pushd $Home; bcdedit /enum bootmgr; pause
As Admin in PWSH.exe
its self.
# test.ps1$AL = "-NoProfile -WindowStyle Maximized -ExecutionPolicy Bypass", "-Command", "Pushd $Home; bcdedit /enum bootmgr; pause"Start -Verb RunAs -FilePath pwsh.exe -ArgumentList $AL
What is the writing format, if I execute it (test.ps1
), then will opened in Windows Terminal Elevated/ As Admin?
I tried:
# test.ps1$AL = "-M -p 'PowerShell'", "pwsh.exe -ExecutionPolicy Bypass -Command `"Pushd $Home; bcdedit /enum bootmgr; pause`""Start -Verb RunAs -FilePath wt.exe -ArgumentList $AL
giving the errors:
[error 2147942402 (0x80070002) when launching `" pause"']
[error 2147942402 (0x80070002) when launching `" bcdedit /enum bootmgr"']
I have also tried other formats but the error still persists.
Only works if one command:
# test.ps1$AL = "-M -p 'PowerShell'", "pwsh.exe -ExecutionPolicy Bypass -Command `"bcdedit /enum bootmgr`""Start -Verb RunAs -FilePath wt.exe -ArgumentList $AL