使用PowerShell关闭远程机器上的进程
2016-11-15 15:16
369 查看
原文地址:http://rakhesh.com/powershell/killing-a-process-on-a-remote-computer-using-powershell/
在本地计算机上关闭进程的方式:
(Get-Process -Name notepad2).Kill()
Stop-Process -Name notepad2
Get-Process -Name notepad2 | Stop-Process
以上几种方法虽然在本地计算机上能够正常工作,但是都不能应用在远程计算机上。
stop-process命令不支持-ComputerName参数,如果给第三种方法添加-ComputerName参数来关闭远程进程的话会出现“Stop-Process : Feature is not supported for remote machines”异常。而第一种方法会出现“Exception calling "Kill" with "0" argument(s): "Feature is not supported for remote machines."异常。
所以我们只能使用WMI来关闭远程进程了:
(Get-WmiObject Win32_Process -ComputerName mango | ?{ $_.ProcessName -match "notepad" }).Terminate()
如果你想知道当前的进程支持什么方法,可以使用以下方法进行查看:
gwmi win32_process | ?{ $_.ProcessName -match "notepad" } | gm -MemberType Method
在本地计算机上关闭进程的方式:
(Get-Process -Name notepad2).Kill()
Stop-Process -Name notepad2
Get-Process -Name notepad2 | Stop-Process
以上几种方法虽然在本地计算机上能够正常工作,但是都不能应用在远程计算机上。
stop-process命令不支持-ComputerName参数,如果给第三种方法添加-ComputerName参数来关闭远程进程的话会出现“Stop-Process : Feature is not supported for remote machines”异常。而第一种方法会出现“Exception calling "Kill" with "0" argument(s): "Feature is not supported for remote machines."异常。
所以我们只能使用WMI来关闭远程进程了:
(Get-WmiObject Win32_Process -ComputerName mango | ?{ $_.ProcessName -match "notepad" }).Terminate()
如果你想知道当前的进程支持什么方法,可以使用以下方法进行查看:
gwmi win32_process | ?{ $_.ProcessName -match "notepad" } | gm -MemberType Method
相关文章推荐
- vb.net中使用wmi关闭远程计算机上的进程
- vb.net中使用wmi关闭远程计算机上的进程
- 多进程监控自动关机工具升级远程关闭多台server——C# works with PowerShell
- 如何关闭本地和远程NT/2000系统进程
- 使用gFtp时显示远程登录机器中文的方法
- 使用OutLook远程控制机器
- 远程计算机进程的查看与关闭
- C#强制关闭Excel进程(通过COM使用Excel时)
- 使用WMI获取远程机器操作系统的详细信息
- PowerShell 2.0远程管理开发使用CredSSP处理多跳授权
- 使用完excel后,如何关闭进程(C#)
- 使用ssh自动登录远程机器
- 使用 User Mode Process Dumper 为异常关闭或停止响应的进程保存转储文件
- 使用远程线程制作不死进程
- 使用远程线程制作不死进程
- 使用WMI获取远程机器的时间
- 关闭SQL SERVER用户进程,防止因为用户正在使用数据库,导致数据库恢复或删除失败
- 在同个域中或相同的网段中使用SqlServer2000连接远程机器数据库的Jobs
- ASP.NET使用WEB关闭进程process.Kill(); 的时候,出现拒绝访问的提示解决方案
- putty关闭后,后台程序继续运行---使用 screen 管理你的远程会话