Get-WmiObject -class win32_process -ComputerName with multiple where{$_.ProcessName -eq
i trying write script query multiple servers multiple processes each process thread count. see below have working 1 process , output displays below.
get-wmiobject -class win32_process -computername server1,server2,server3,server4 | where{$_.processname -eq "notepad.exe"} | select-object processname, handles, threadcount | sort-object $_.processname -descending | ft -auto
processname handles threadcount
----------- ------- -----------
notepad.exe 50 1
notepad.exe 50 1
notepad.exe 50 1
notepad.exe 50 1
is possible multiple statements such {$_.processname -eq "'notepad.exe','paint.exe','winlogon.exe','excel.exe'"}. i have tried failed. what proper way query muliple servers multiple processes? i looking ideas little unsure of how go script.
sample output of wanting.
csname processname handles threadcount
------ ----------- ------- -----------
server1 notepad.exe 316 25
server1 mspaint.exe 316 25
server1 winlogon.exe 305 21
server1 excel.exe 305 21
server2 notepad.exe 5993 404
server2 mspaint.exe 5736 389
server2 winlogon.exe 5024 150
server2 excel.exe 5026 150
server3 notepad.exe 316 25
server3 mspaint.exe 316 25
server3 winlogon.exe 305 21
server3 excel.exe 305 21
server4 notepad.exe 5993 404
server4 mspaint.exe 5736 389
server4 winlogon.exe 5024 150
server4 excel.exe 5026 150
get-wmiobject -class win32_process -computername server1,server2,server3,server4 | where{$_.processname -eq "notepad.exe"} | select-object processname, handles, threadcount | sort-object $_.processname -descending | ft -auto
processname handles threadcount
----------- ------- -----------
notepad.exe 50 1
notepad.exe 50 1
notepad.exe 50 1
notepad.exe 50 1
is possible multiple statements such {$_.processname -eq "'notepad.exe','paint.exe','winlogon.exe','excel.exe'"}. i have tried failed. what proper way query muliple servers multiple processes? i looking ideas little unsure of how go script.
sample output of wanting.
csname processname handles threadcount
------ ----------- ------- -----------
server1 notepad.exe 316 25
server1 mspaint.exe 316 25
server1 winlogon.exe 305 21
server1 excel.exe 305 21
server2 notepad.exe 5993 404
server2 mspaint.exe 5736 389
server2 winlogon.exe 5024 150
server2 excel.exe 5026 150
server3 notepad.exe 316 25
server3 mspaint.exe 316 25
server3 winlogon.exe 305 21
server3 excel.exe 305 21
server4 notepad.exe 5993 404
server4 mspaint.exe 5736 389
server4 winlogon.exe 5024 150
server4 excel.exe 5026 150
thank , time, robert jaudon
hi robert,
this possible using -contains operator (you can read more comparison operators here:
$procnames='notepad.exe','paint.exe','winlogon.exe','excel.exe' get-wmiobject -class win32_process -computername server1,server2,server3,server4 | where{$procnames -contains $_.processname} | select-object processname, handles, threadcount | sort-object $_.processname -descending | ft -auto
Windows Server > Windows PowerShell
Comments
Post a Comment