Powershell - Simple ping and query


  • 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;      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.



    Rob from Sydney


    24 Ocak 2012 Salı 23:52


Tüm Yanıtlar

  • 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?


    25 Ocak 2012 Çarşamba 00:07
  • 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.




    25 Ocak 2012 Çarşamba 00:20
  • There are many examples of using Excel files for input and output in the script repository.


    25 Ocak 2012 Çarşamba 00:30
  • 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
    Windows System Administration tool
    AD User Creation tool

    19 Şubat 2012 Pazar 20:45