I would like, from a powershell script, launch another powershell instance in administrator mode and, if possible, indicate to it some code to be executed in this same command line.
Here is the concrete case (I am using chocolatey for my package management under windows) :
Start-Process powershell -Verb runAs -ArgumentList "choco outdated"
This code works, but unfortunately the powershell window closes immediately after executing the code. So it is "impossible" to see outdated packages.
Do you have a solution for either:
- freeze the script after the command?
- or add more line of code to put
Start-Sleep -Seconds 10
? - or another solution?
Thanks in advance!