我正在运行以下代码以检查某些程序是否正在运行。
##This Script is for checking status of 3 processes TestMgr.exe, iTestConsole.exe and tdefine.exe in all testBed machines
##Machine TestBed name and IP needs to be provided from a seperate text file TestBeds.txt. Should be put in same directory
##Output would go to a CSV file testBedProcessReport.csv in the same directory
##function assign is to assign status to various processes involved
function assign($process){
if($process -eq $null){return $creds}
elseif($process.count -eq $null){return "Running"}
else {return "cannot be determined"}
}
##getting data from external sheet with test bed and IP details
$allTestBeds = Get-Content \\gal71810.fs1.util.jlrint.com\powertrain\PT\PT-8\PT-83\PT-833\Shared\TestbedTools\Gaydon\ASAPMaster\Testbeds.txt
[psobject[]]$testBedStatus = ""
$all_process = ""
$creds = Get-Credential
##looping all test bed details to check process status
foreach($testBed in $allTestBeds){
$temp = $testBed -split "="
$testBedName = $temp[0] + ""
$computerIP = $temp[1]
$status = New-Object -TypeName psobject
Add-Member -InputObject $status -MemberType NoteProperty -Name TBName -Value $testBedName
Add-Member -InputObject $status -MemberType NoteProperty -Name TestMgr -Value "Running"
Add-Member -InputObject $status -MemberType NoteProperty -Name iTestConsole -Value "Running"
Add-Member -InputObject $status -MemberType NoteProperty -Name Tdefine -Value "Running"
##getting all process details by connecting to WMI service
$all_process = Get-WmiObject -Class Win32_Process -ComputerName $computerIP -Credential $creds
If($all_process -eq $null){
continue;
}
##Unique is used in case same exe is running many instances
$TestMgr = $all_process | where-object{$_.path -like "*TestMgr.exe*"} | select path -Unique
$status.TestMgr = assign($TestMgr)
$iTestConsole = $all_process | where-object{$_.path -like "*iTestConsole.exe*"} | select path -Unique
$status.iTestConsole = assign($iTestConsole)
$tdefine = $all_process | where-object{$_.path -like "*tdefine.exe*"} | select path -Unique
$status.tdefine = assign($tdefine)
$testBedStatus = $testBedStatus + $status
}
$testBedStatus | out-file \\gal71810.fs1.util.jlrint.com\powertrain\PT\PT-8\PT-83\PT-833\Shared\TestbedTools\Gaydon\ASAPMaster\TestBedStatus.csv
在另一台工作完全相同的PC上,可以正常运行。 我知道IP正常,因为我可以打开文件浏览器,并使用IP查看共享目录。 IP也是可ping通的。 使用nslookup检查IP是否返回正确的主机名,并且主机名返回正确的IP。 我检查了防火墙,可以了 我已经检查了services.msc并确保RPC WMI服务正在运行。 我已经检查了注册表值 我检查了Internet连接及其协议
有很多想法