Training
Module
Select, sort, and measure objects using the pipeline - Training
This module explains how to manipulate objects in the pipeline by using commands that sort, select, and measure objects.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
You can use the Select-Object
cmdlet to create new, custom PowerShell objects that contain
properties selected from the objects you use to create them. Type the following command to create a
new object that includes only the Name and FreeSpace properties of the Win32_LogicalDisk
WMI class:
Get-CimInstance -Class Win32_LogicalDisk |
Select-Object -Property Name, FreeSpace
Name FreeSpace
---- ---------
C: 50664845312
With Select-Object
you can create calculated properties to display FreeSpace in gigabytes
rather than bytes.
Get-CimInstance -Class Win32_LogicalDisk |
Select-Object -Property Name, @{
Label='FreeSpace'
Expression={($_.FreeSpace/1GB).ToString('F2')}
}
Name FreeSpace
---- ---------
C: 47.18
PowerShell feedback
PowerShell is an open source project. Select a link to provide feedback:
Training
Module
Select, sort, and measure objects using the pipeline - Training
This module explains how to manipulate objects in the pipeline by using commands that sort, select, and measure objects.