【发布时间】:2014-04-11 16:40:03
【问题描述】:
此代码确实有效.. 但是,我无法确定它是 Notepad.exe 还是 TextPad.exe.. $a.Name 变量不起作用..
$log = "D:\WORK\ps\duplicate.txt"
If (test-path -path $log) {
Remove-Item $log
}
##$query = "Select * from win32_Process where name like '%script%'"
$query = "Select * from win32_Process where name like '%pad%'"
#$a = Get-WmiObject -Query $query | select name, processID | sort name
$SERVERS = get-content -Path D:\WORK\ps\monitored_computers.txt
$(Foreach ($server in $SERVERS) {
$a = Get-WmiObject -Query $query -ComputerName $server | select name, processID | sort name
IF ($a.Count -gt 1 ) { $server + " count: " + $a.Count + " name: " + $a.name | Out-File -append -filepath $log -encoding ASCII }
})
If (test-path -path $log) {
send-mailmessage -from "sender@company.com" -to "receiver@company.com" -subject "Duplicated processes" -body "Please see attached" -Attachment $log -dno onSuccess, onFailure -smtpServer smpthost.company.com
}
【问题讨论】:
-
您能否详细说明您要完成的工作?
-
我正在设置一个监视器(计划任务),让我们知道我们是否有任何挂起或卡住的 Wscript/Cscript 进程..我已经在 VBScript 下完成了..
标签: powershell process wmi