Last active
October 9, 2020 20:28
-
-
Save Groostav/15ed0b2bad3d8169901ff19d08cd7c4b to your computer and use it in GitHub Desktop.
what is powershells Stop-Process doing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Write-Host "Host Version:" $Host.Version | |
Try | |
{ | |
Write-Host "before!" | |
Stop-Process 123456789 -EA Stop | |
Write-Host "after!" | |
} | |
Catch | |
{ | |
Write-Host "caught red handed!" | |
} | |
Finally | |
{ | |
Write-Host "finally!" | |
} | |
<# | |
C:\Users\geoff\Desktop> .\Testing-Try-Catch.ps1 | |
Host Version: 5.1.19041.1 | |
before! | |
caught red handed! | |
finally! | |
#> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Write-Host "Host Version:" $Host.Version | |
Try | |
{ | |
Write-Host "before!" | |
Stop-Process 123456789 | |
Write-Host "after!" | |
} | |
Catch | |
{ | |
Write-Host "caught red handed!" | |
} | |
Finally | |
{ | |
Write-Host "finally!" | |
} | |
<# | |
C:\Users\geoff\Desktop> .\Testing-Try-Catch.ps1 | |
Host Version: 5.1.19041.1 | |
before! | |
Stop-Process : Cannot find a process with the process identifier 123456789. | |
At C:\Users\geoff\Desktop\Testing-Try-Catch.ps1:6 char:5 | |
+ Stop-Process 123456789 | |
+ ~~~~~~~~~~~~~~~~~~~~~~ | |
+ CategoryInfo : ObjectNotFound: (123456789:Int32) [Stop-Process], ProcessCommandException | |
+ FullyQualifiedErrorId : NoProcessFoundForGivenId,Microsoft.PowerShell.Commands.StopProcessCommand | |
after! | |
#> | |
finally! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
what a pain in the butt.