PowerShell for Windows Admins

Jun 6 2011   1:57PM GMT

Get-WmiObject property parameter



Posted by: Richard Siddaway
PowerShell v2

This is a fairly obvious piece of PowerShell

Get-WmiObject Win32_Volume

We would probably restrict the properties we displayed like this

Get-WmiObject Win32_Volume | select DriveLetter, DriveType, Freespace

or possibly

Get-WmiObject Win32_Volume |
format-table DriveLetter, DriveType, Freespace –AutoSize

If we are dealing with a large number of remote machines we may want to restrict the properties we return – this is where we use the –property parameter

Get-WmiObject Win32_Volume -property @("DriveLetter", "DriveType", "Freespace")

NOTE THIS STILL RETURNS THE SYSTEM PROPERTIES

so to get a good display we would want to still use format-table (or select)

Get-WmiObject Win32_Volume -property @("DriveLetter", "DriveType", "Freespace") |
format-table DriveLetter, DriveType, Freespace –AutoSize

The –property parameter gives us another opportunity to restrict the data returned to reduce network traffic but we still need to format the returned data

Comment on this Post

Leave a comment: