Powershell - Simple ping and query
-
2012년 1월 24일 화요일 오후 11: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일 화요일 오후 11:54
모든 응답
-
2012년 1월 25일 수요일 오전 12: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일 수요일 오전 12: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일 수요일 오전 12:30
There are many examples of using Excel files for input and output in the script repository.
jv -
2012년 2월 19일 일요일 오후 8: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일 일요일 오후 11:56
- 답변으로 표시됨 IamMredMicrosoft Employee, Owner 2012년 2월 20일 월요일 오전 5:28

