Advertisement
DGorka

WMI Process Remote

Aug 3rd, 2016
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #    ____  ____  ____________
  2. #   / __ \/ __ \/_  __/ ____/
  3. #  / /_/ / /_/ / / / / / __  
  4. # / ____/ _, _/ / / / /_/ /  
  5. #/_/   /_/ |_| /_/  \____/                        
  6. #    NETWORK MONITOR
  7. #-------------------
  8. #(c) 2016 Stephan Linke, Paessler AG
  9. #
  10. #This script checks if a certain dynamic process is running on a remote machine.
  11. #
  12.  
  13. # Parameter "-computername" for the remote hosts address and "-proc" for the dynamic process name
  14. param(
  15.     $computername = "localhost",
  16.     $proc = "proc"
  17.     )
  18.  
  19. # Get processes of the remote machine that are like the provided dynamic process name
  20. $Processes = (Get-WmiObject -ComputerName $computername -Query "SELECT * FROM Win32_Process WHERE NAME LIKE '%$($proc)%'")
  21.  
  22. # Check if the process is found or not, report it back to PRTG.
  23. if([string]::IsNullOrEmpty($Processes)) {
  24.     Write-Host ([string]::Format("{0}:{0} Process not found {1}.",0,$proc));
  25. } else {
  26.     Write-Host ([string]::Format("{0}:{0} Process found {1}.",1,$proc));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement