powershell - 试图找出一个脚本来使用powershell在本地网络上停止特定用户下的进程
问题描述
我需要一个脚本来终止特定用户在本地网络上运行的进程。
我用了
(get-wmiobject Win32_process -ComputerName thepcname |
? {$_.ProcessName -match "notepad" }).Terminate()
但也需要用户指定。请问我该怎么做?
解决方案
您可以使用:
Get-Process -ComputerName thepcname -IncludeUserName
然后过滤$_.UserName
请注意,这将需要管理员权限。
推荐阅读
- python-3.x - 如何在作为具有多个字典的列表的一部分的字典中查找键的值。(从 api 中提取
- python - 字符串列表中的模式匹配,在熊猫中创建新列
- javascript - 如何在 twilio api 中使用分页?
- python - 将 QGraphicsDropShadowEffect 与多个小部件一起使用
- ruby-on-rails - ActionCable - 连接已执行但未连接
- tinybutstrong - Onformat 的多个参数
- php - 如何从将内容添加到单个帖子模板的过滤器中省略特定帖子?
- html - 为什么调整导航栏大小时我的图像消失
- dialogflow-es - 如何使用 actions-on-google 包的“dialogFlow”模块创建我自己的 DialogFlow 实现网络挂钩?
- vba - VBA-复制没有特定列的行