Powershell - Simple ping and query
-
2012年1月24日 23:52
Hi guys,
Im trying to write an ps script that will simply ping all pc's within domain , and check if a process is running on them.
Currently i have a script that pings and exports names of pc's and thier ip's;
http://www.youdidwhatwithtsql.com/ping-all-domain-computers-with-powershell/209#ixzz1kQG467Td into excel respective .xls files...
What i would like, to is is check the alive pc's and see if they are running a specified prices , i was hoping to use something like;
Get-Process xxxxxxxxx > output.txt to search for the application and then export user and pc details to a final report.
OR to create a filter where only pc's and Ip's where the process (and its respective details, pid and uptime) is running are writen to a file / report.
If anyone can help or has ideas, please reply and if appropriate i would be happy to offer reward.
thanks,
Rob from Sydney
- 編集済み phillipsydney 2012年1月24日 23:54
すべての返信
-
2012年1月25日 0:07
Your question is too vague. What specifically are you having trouble with.
YOu did not write the script you linked in here. It has nothing to do with gettingprocesses..
Type help get-process -full to see how to use get-process.
It is completely unclear what you mean by creating a filter? To filter what?
jv -
2012年1月25日 0:20
Basically,
I dont know how to use the get-process command, so that i can read an excel file, with computer name and ip data , and check weather the pc from list is running an specified process.
The output from the ping script (above) , writes the results in excel sheet , vaules $computer,$ipAddress , starting in A1 and B1
It is completely unclear what you mean by creating a filter? To filter what? -- i was wondering if the process check could be combined into the ping all script so that only the pc/ips with the specified process are recorded to output.
thanks,
Igor
-
2012年1月25日 0:30
There are many examples of using Excel files for input and output in the script repository.
jv -
2012年2月19日 20:45モデレータ
This script should suit for what you requested. You can modify it further for anything else required.$Proc = "MyProc.exe" $PCs = get-content pclist.txt $Output = ProcStatus.txt "$(Get-Date) - Checking for status of $Proc" | Out-File $Output foreach ($PC in $PCs){ "Processing $PC" if (test-connection $PC -Quiet -Count 1){ if (Get-Process $Proc -ComputerName $PC){ "$Proc is running on $PC" | Out-File $Output -Append } else { "$Proc is not running on $PC" | Out-File $Output -Append } } else { "Could not contact $PC" | Out-File $Output -Append }Rich Prescott | Infrastructure Architect, Windows Engineer and PowerShell blogger | MCITP, MCTS, MCP
Engineering Efficiency
@Rich_Prescott
Windows System Administration tool
AD User Creation tool- 回答の候補に設定 Richard MuellerMVP, Moderator 2012年2月19日 23:56
- 回答としてマーク IamMredMicrosoft Employee, Owner 2012年2月20日 5:28

