Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
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