I'm trying to run a powershell script from cmd with elevated privileges, but I need to pass a parameter to the powershell script. This is the code of the batch file I'm using:
echo off
cls
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& {Start-Process PowerShell -Verb runas -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File ""%~dp0\MigrationTool.ps1 -ConfigFile ConfigFile.xml""'}"
When I use the code above, the script does nothing.
If I run the script without the -ConfigFile parameter, the script runs, then it prompts me to type the config file. Although I get prompted and then I just type in the config file, the script still doesn't work.
I did a little bit of digging on the Internet but couldn't find any solution.
Thanks.
runastool."". cmd and powershell escape differently.