Hi All,
Having some issues with an admin task that is designed to run via command line in powershell.
The task requires escalated privilege to run but when doing this the '-Wait' option does not work.
The code line is: Start-Process cmd $msbsaCmd -Verb RunAs -Wait
Although this successfully elevates privilege on the command prompt it ignores the wait option.
However, if the saved powershell script is run as admin (Right Click, Run as Admin) the wait string works.
Is there a way that I can set this to wait for the command to complete despite it running as admin?
I am trying to resolve this myself as well so I can let you know if I have any luck with this.
Full Code String Example,
try { $msbsaCmd = 'cmd /c "C:\Program Files\Microsoft Baseline Security Analyzer 2\mbsacli.exe" /target 127.0.0.1 /n os > C:\temp\mbsacli.txt'
Start-Process cmd $msbsaCmd -Verb RunAs -Wait }
catch { echo '' 'Error Running MS BSA 2.3, Ensure you have Run this script as Administrator' '' }