//
stai leggendo...
domanda

Scripting Games–filtering on remote server

Richard Siddaway's Blog

In event 3 you have to get information on hard disk capacity.  I’ve only looked at the first couple of dozen scripts but seen this too many times

Get-WmiObject -Class Win32_LogicalDisk | where DriveType -eq 3

or if you prefer the version 2 way

Get-WmiObject -Class Win32_LogicalDisk | where {$_.DriveType -eq 3}

If puppies get terminated for using Write-Host this sort of construct should triggers a mass extinction.

When pulling information back with WMI (or any other technique) from a remote server ALWAYS, ALWAYS, ALWAYS filter on the remote server.  What you are doing here is pulling back all of the data and filtering on the client. This is grossly inefficient when you are dealing with hundreds of machines.

The PowerShell team gave us the –Filter parameter on Get-WmiObject for a reason. Its to do the filtering on the remote server.

Get-WmiObject -Class Win32_LogicalDisk -Filter “DriveType = 3”

If you…

View original post 31 altre parole

Discussione

Non c'è ancora nessun commento.

Lascia un commento