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:
Start-Sleep -Seconds 10
?Thanks in advance!
Here's one way to get it to wait.
Start-Process powershell -Verb runAs -ArgumentList "choco outdated`n`rpause"