杀进程

 

 我喜欢的写法:

 ps SQLQueryStress |Stop-Process

 

 

 

#1.纯cmdlet命令
Get-Process -Name notepad | Stop-Process

#2.cmdlet+遍历
Get-Process -Name notepad | foreach-object{$_.Kill()} 

#3.WMI 对象 + 遍历 + 对象方法 
Get-WmiObject Win32_Process -Filter "name = 'notepad.exe'" | ForEach-Object{$_.Terminate()  | Out-Null }

#4.WMI 对象 + 遍历 + cmdlet方法
Get-WmiObject Win32_Process -Filter "name = 'notepad.exe'" | Invoke-WmiMethod -Name Terminate | Out-Null


 

 

 

转载来源:https://blog.csdn.net/HoKis/article/details/79007546/
posted @ 2020-03-17 10:25  JinweiChang  阅读(121)  评论(0编辑  收藏  举报