Get-Disk
Updated: August 15, 2012
Applies To: Windows Server 2012
Get-Disk
Syntax
Parameter Set: ByNumber Get-Disk [[-Number] <UInt32[]> ] [-AsJob] [-CimSession <CimSession[]> ] [-ThrottleLimit <Int32> ] [ <CommonParameters>] Parameter Set: ByiSCSIConnection Get-Disk [-AsJob] [-CimSession <CimSession[]> ] [-iSCSIConnection <CimInstance> ] [-ThrottleLimit <Int32> ] [ <CommonParameters>] Parameter Set: ByiSCSISession Get-Disk [-AsJob] [-CimSession <CimSession[]> ] [-iSCSISession <CimInstance> ] [-ThrottleLimit <Int32> ] [ <CommonParameters>] Parameter Set: ByName Get-Disk [-AsJob] [-CimSession <CimSession[]> ] [-FriendlyName <String[]> ] [-ThrottleLimit <Int32> ] [ <CommonParameters>] Parameter Set: ByPartition Get-Disk [-AsJob] [-CimSession <CimSession[]> ] [-Partition <CimInstance> ] [-ThrottleLimit <Int32> ] [ <CommonParameters>] Parameter Set: ByPath Get-Disk [-AsJob] [-CimSession <CimSession[]> ] [-Path <String[]> ] [-ThrottleLimit <Int32> ] [ <CommonParameters>] Parameter Set: ByUniqueId Get-Disk [-AsJob] [-CimSession <CimSession[]> ] [-ThrottleLimit <Int32> ] [-UniqueId <String[]> ] [ <CommonParameters>] Parameter Set: ByVirtualDisk Get-Disk [-AsJob] [-CimSession <CimSession[]> ] [-ThrottleLimit <Int32> ] [-VirtualDisk <CimInstance> ] [ <CommonParameters>]
Detailed Description
The Get-Disk cmdlet gets one or more Disk objects visible to the operating system, or optionally a filtered list.
Parameters
-AsJob
Runs the cmdlet as a background job. Use this parameter to run commands that take a long time to complete. The cmdlet immediately returns an object that represents the job and then displays the command prompt. You can continue to work in the session while the job completes. To manage the job, use the *-Job cmdlets. To get the job results, use the Receive-Job cmdlet. For more information about Windows PowerShell® background jobs, see about_Jobs.
|
Aliases |
none |
|
Required? |
false |
|
Position? |
named |
|
Default Value |
none |
|
Accept Pipeline Input? |
false |
|
Accept Wildcard Characters? |
false |
-CimSession<CimSession[]>
Runs the cmdlet in a remote session or on a remote computer. Enter a computer name or a session object, such as the output of a New-CimSession or Get-CimSession cmdlet. The default is the current session on the local computer.
|
Aliases |
Session |
|
Required? |
false |
|
Position? |
named |
|
Default Value |
none |
|
Accept Pipeline Input? |
false |
|
Accept Wildcard Characters? |
false |
-FriendlyName<String[]>
Gets the disk with the specified friendly name. Enter a friendly name, or use wildcard characters to enter a name pattern.
|
Aliases |
none |
|
Required? |
false |
|
Position? |
named |
|
Default Value |
none |
|
Accept Pipeline Input? |
false |
|
Accept Wildcard Characters? |
false |
-Number<UInt32[]>
Specifies the disk number for which to get the associated Disk object.
|
Aliases |
DeviceId |
|
Required? |
false |
|
Position? |
1 |
|
Default Value |
none |
|
Accept Pipeline Input? |
True (ByPropertyName) |
|
Accept Wildcard Characters? |
false |
-Partition<CimInstance>
Accepts a Partition object as input. The Partition CIM object is exposed by the Get-Partition cmdlet.
|
Aliases |
none |
|
Required? |
false |
|
Position? |
named |
|
Default Value |
none |
|
Accept Pipeline Input? |
True (ByValue) |
|
Accept Wildcard Characters? |
false |
-Path<String[]>
Contains valid path information.
|
Aliases |
none |
|
Required? |
false |
|
Position? |
named |
|
Default Value |
none |
|
Accept Pipeline Input? |
True (ByPropertyName) |
|
Accept Wildcard Characters? |
false |
-ThrottleLimit<Int32>
Specifies the maximum number of concurrent operations that can be established to run the cmdlet. If this parameter is omitted or a value of 0 is entered, then Windows PowerShell® calculates an optimum throttle limit for the cmdlet based on the number of CIM cmdlets that are running on the computer. The throttle limit applies only to the current cmdlet, not to the session or to the computer.
|
Aliases |
none |
|
Required? |
false |
|
Position? |
named |
|
Default Value |
none |
|
Accept Pipeline Input? |
false |
|
Accept Wildcard Characters? |
false |
-UniqueId<String[]>
Gets only the disks with the specified IDs. Type one or more IDs (separated by commas).
|
Aliases |
Id |
|
Required? |
false |
|
Position? |
named |
|
Default Value |
none |
|
Accept Pipeline Input? |
false |
|
Accept Wildcard Characters? |
false |
-VirtualDisk<CimInstance>
Accepts a VirtualDisk object as input. The Virtual Disk CIM object is exposed by the Get-VirtualDisk cmdlet.
|
Aliases |
none |
|
Required? |
false |
|
Position? |
named |
|
Default Value |
none |
|
Accept Pipeline Input? |
True (ByValue) |
|
Accept Wildcard Characters? |
false |
-iSCSIConnection<CimInstance>
Accepts an iSCSIConnection object as input. The iSCSI Connection CIM object is exposed by the Get-IscsiConnection cmdlet.
|
Aliases |
none |
|
Required? |
false |
|
Position? |
named |
|
Default Value |
none |
|
Accept Pipeline Input? |
True (ByValue) |
|
Accept Wildcard Characters? |
false |
-iSCSISession<CimInstance>
Accepts an iSCSISession object as input. The iSCSI Session CIM object is exposed by the Get-IscsiSession cmdlet.
|
Aliases |
none |
|
Required? |
false |
|
Position? |
named |
|
Default Value |
none |
|
Accept Pipeline Input? |
True (ByValue) |
|
Accept Wildcard Characters? |
false |
<CommonParameters>
This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see about_CommonParameters.
Inputs
The input type is the type of the objects that you can pipe to the cmdlet.
-
Microsoft.Management.Infrastructure.CimInstance#ROOT/Microsoft/Windows/Storage/MSFT_IscsiConnection
You can pipe an iSCSIConnection object to the iSCSIConnection parameter.
-
Microsoft.Management.Infrastructure.CimInstance#ROOT/Microsoft/Windows/Storage/MSFT_IscsiSession
You can pipe an iSCSISession object to the iSCSISession parameter.
-
Microsoft.Management.Infrastructure.CimInstance#ROOT/Microsoft/Windows/Storage/MSFT_Partition
You can pipe a Parition object to the Partition parameter.
-
Microsoft.Management.Infrastructure.CimInstance#ROOT/Microsoft/Windows/Storage/MSFT_VirtualDisk
You can pipe a VirtualDisk object to the VirtualDisk parameter.
Outputs
The output type is the type of the objects that the cmdlet emits.
-
Microsoft.Management.Infrastructure.CimInstance#ROOT/Microsoft/Windows/Storage/MSFT_Disk
This cmdlet outputs one or more objects representing disks.
Notes
-
The
Microsoft.Management.Infrastructure.CimInstanceobject is a wrapper class that displays Windows Management Instrumentation (WMI) objects. The path after the pound sign (#) provides the namespace and class name for the underlying WMI object.
Examples
Example 1: Get all disks
This example gets all disks visible to the operating system.
PS C:\> Get-Disk
Example 2: Get a disk by disk number
This example gets disk 6.
PS C:\> Get-Disk -Number 6
Example 3: Get all USB disks
This example gets all disks attached via the USB bus by piping the output of Get-Disk to the Where-Object cmdlet, and filtering by the USB value of the Bustype property.
PS C:\> Get-Disk | Where-Object –FilterScript {$_.Bustype -Eq "USB"}
Example 4: Get the iSCSI sessions for all iSCSI disks
This example gets all disks attached via the iSCSI bus by piping the output of Get-Disk to the Where-Object cmdlet, and filtering by the iSCSI value of the Bustype property. It then passes the Disk objects in the pipeline to the Get-IscisSession cmdlet, which gets the associated iSCSI sessions, and then pipes the output to the Format-Table cmdlet for simplified display.
PS C:\> Get-Disk | Where-Object –FilterScript {$_.BusType -Eq "iSCSI"} |
Get-IscsiSession | Format-Table
Related topics
