Powershell - Simple ping and query
-
24 января 2012 г. 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 24 января 2012 г. 23:54
Все ответы
-
25 января 2012 г. 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 -
25 января 2012 г. 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
-
25 января 2012 г. 0:30
There are many examples of using Excel files for input and output in the script repository.
jv -
19 февраля 2012 г. 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 19 февраля 2012 г. 23:56
- Помечено в качестве ответа IamMredMicrosoft Employee, Owner 20 февраля 2012 г. 5:28

