Get-Disk
Gets one or more disks visible to the operating system.
Note
This cmdlet returns physical disk objects like basic disks and partitioned drive partitions. Dynamic disks can span multiple pieces of physical media, so they will not be returned by Get-Disk. For more information, see Basic and Dynamic Disks.
Syntax
ByNumber (Default)
Get-Disk
[[-Number] <UInt32[]>]
[-CimSession <CimSession[]>]
[-ThrottleLimit <Int32>]
[-AsJob]
[<CommonParameters>]
ByUniqueId
Get-Disk
[-UniqueId <String[]>]
[-CimSession <CimSession[]>]
[-ThrottleLimit <Int32>]
[-AsJob]
[<CommonParameters>]
ByName
Get-Disk
[-FriendlyName <String[]>]
[-SerialNumber <String[]>]
[-CimSession <CimSession[]>]
[-ThrottleLimit <Int32>]
[-AsJob]
[<CommonParameters>]
ByPath
Get-Disk
[-Path <String[]>]
[-CimSession <CimSession[]>]
[-ThrottleLimit <Int32>]
[-AsJob]
[<CommonParameters>]
ByPartition
Get-Disk
[-Partition <CimInstance>]
[-CimSession <CimSession[]>]
[-ThrottleLimit <Int32>]
[-AsJob]
[<CommonParameters>]
ByVirtualDisk
Get-Disk
[-VirtualDisk <CimInstance>]
[-CimSession <CimSession[]>]
[-ThrottleLimit <Int32>]
[-AsJob]
[<CommonParameters>]
ByiSCSISession
Get-Disk
[-iSCSISession <CimInstance>]
[-CimSession <CimSession[]>]
[-ThrottleLimit <Int32>]
[-AsJob]
[<CommonParameters>]
ByiSCSIConnection
Get-Disk
[-iSCSIConnection <CimInstance>]
[-CimSession <CimSession[]>]
[-ThrottleLimit <Int32>]
[-AsJob]
[<CommonParameters>]
ByStorageSubSystem
Get-Disk
[-StorageSubSystem <CimInstance>]
[-CimSession <CimSession[]>]
[-ThrottleLimit <Int32>]
[-AsJob]
[<CommonParameters>]
ByStorageNode
Get-Disk
[-StorageNode <CimInstance>]
[-CimSession <CimSession[]>]
[-ThrottleLimit <Int32>]
[-AsJob]
[<CommonParameters>]
ByStorageJob
Get-Disk
[-StorageJob <CimInstance>]
[-CimSession <CimSession[]>]
[-ThrottleLimit <Int32>]
[-AsJob]
[<CommonParameters>]
Description
The Get-Disk cmdlet gets one or more Disk objects visible to the operating system, or optionally a filtered list.
Examples
Example 1: Get all disks
PS C:\>Get-Disk
This example gets all disks visible to the operating system.
Example 2: Get a disk by disk number
PS C:\>Get-Disk -Number 6
This example gets disk 6.
Example 3: Get all USB disks
PS C:\>Get-Disk | Where-Object -FilterScript {$_.Bustype -Eq "USB"}
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.
Example 4: Get the iSCSI sessions for all iSCSI disks
PS C:\>Get-Disk | Where-Object -FilterScript {$_.BusType -Eq "iSCSI"} |
Get-IscsiSession | Format-Table
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-IscsiSession cmdlet, which gets the associated iSCSI sessions, and then pipes the output to the Format-Table cmdlet for simplified display.
Parameters
-AsJob
Runs the cmdlet as a background job. Use this parameter to run commands that take a long time to complete.
Parameter properties
Type: | SwitchParameter |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-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.
Parameter properties
Type: | CimSession[] |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Aliases: | Session |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-FriendlyName
Gets the disk with the specified friendly name. Enter a friendly name, or use wildcard characters to enter a name pattern.
Parameter properties
Type: | String[] |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
ByName
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-iSCSIConnection
Accepts an iSCSIConnection object as input. The iSCSI Connection CIM object is exposed by the Get-IscsiConnection cmdlet.
Parameter properties
Type: | CimInstance |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
ByiSCSIConnection
Position: | Named |
Mandatory: | False |
Value from pipeline: | True |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-iSCSISession
Accepts an iSCSISession object as input. The iSCSI Session CIM object is exposed by the Get-IscsiSession cmdlet.
Parameter properties
Type: | CimInstance |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
ByiSCSISession
Position: | Named |
Mandatory: | False |
Value from pipeline: | True |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-Number
Specifies the disk number for which to get the associated Disk object.
Parameter properties
Type: | UInt32[] |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Aliases: | DeviceId |
Parameter sets
ByNumber
Position: | 0 |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | True |
Value from remaining arguments: | False |
-Partition
Accepts a Partition object as input. The Partition CIM object is exposed by the Get-Partition cmdlet.
Parameter properties
Type: | CimInstance |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
ByPartition
Position: | Named |
Mandatory: | False |
Value from pipeline: | True |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-Path
Contains valid path information.
Parameter properties
Type: | String[] |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
ByPath
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | True |
Value from remaining arguments: | False |
-SerialNumber
Specifies an array of serial numbers associated with disks that this cmdlet gets.
Parameter properties
Type: | String[] |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
ByName
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-StorageJob
Specifies a storage job object that is associated with disks that this cmdlet gets. To obtain a storage job, use the Get-StorageJob cmdlet.
Parameter properties
Type: | CimInstance |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
ByStorageJob
Position: | Named |
Mandatory: | False |
Value from pipeline: | True |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-StorageNode
The Get-Disk cmdlet gets one or more Disk objects visible to the operating system, or optionally a filtered list.
Parameter properties
Type: | CimInstance |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
ByStorageNode
Position: | Named |
Mandatory: | False |
Value from pipeline: | True |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-StorageSubSystem
Specifies the storage subsystem from which this cmdlet gets disks. To obtain a StorageSubsystem object, use the Get-StorageSubSystem cmdlet.
Parameter properties
Type: | CimInstance |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
ByStorageSubSystem
Position: | Named |
Mandatory: | False |
Value from pipeline: | True |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-ThrottleLimit
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.
Parameter properties
Type: | Int32 |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-UniqueId
Gets only the disks with the specified IDs. Type one or more IDs (separated by commas).
Parameter properties
Type: | String[] |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Aliases: | Id |
Parameter sets
ByUniqueId
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-VirtualDisk
Accepts a VirtualDisk object as input. The Virtual Disk CIM object is exposed by the Get-VirtualDisk cmdlet.
Parameter properties
Type: | CimInstance |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
ByVirtualDisk
Position: | Named |
Mandatory: | False |
Value from pipeline: | True |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
Inputs
CimInstance
You can pipe an iSCSIConnection object to the iSCSIConnection parameter.
CimInstance
You can pipe an iSCSISession object to the iSCSISession parameter.
CimInstance
You can pipe a Partition object to the Partition parameter.
CimInstance
You can pipe a VirtualDisk object to the VirtualDisk parameter.
Outputs
CimInstance
This cmdlet outputs one or more objects representing disks.
Notes
- The
Microsoft.Management.Infrastructure.CimInstance
object 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. - Some objects such as disks might include trailing spaces in their friendly names. If you suspect that an object name could have trailing spaces, you can use a wildcard at the end of the name, for example Disk*, or use the Match parameter to instruct Windows PowerShell to include all strings that include the specified characters, instead of only strings that include only the specified characters.
- When used in Failover Cluster, cmdlets from the Storage module operate on cluster level (all servers in the cluster).