Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Debugging a PS script in another PowerShell Window with elevated credentials

$
0
0
 

Hi

Hi want to call another a Powershell script from within my current script and run it with elevated credentials. Ideally I want to hit a break point in the second script or at least capture the output. 

$targetScriptPath = Join-Path $scriptFolder "\HelloWorld.ps1"     

Start-Process $PSHOME\powershell.exe `
                -Credential $wizzyAccountCredentials `
                -ArgumentList "-Command Start-Process $PSHOME\powershell.exe -ArgumentList `"'$targetScriptPath'`" -Verb Runas" -Wait

The script seems to run and I do get my second PS window but I don't see any of my test Write_Host commands.  Feel free to suggest any improvements to the above script. 

Daniel




Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>