Get-Disk
Get-Disk
Gets one or more disks visible to the operating system.
語法
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>]
詳細描述
The Get-Disk cmdlet gets one or more Disk objects visible to the operating system, or optionally a filtered list.
參數
-AsJob
別名 |
無 |
必要? |
false |
位置? |
named |
預設值 |
無 |
接受管線輸入? |
false |
接受萬用字元? |
false |
-CimSession<CimSession[]>
在遠端工作階段或遠端電腦上執行 Cmdlet。輸入電腦名稱或工作階段物件,例如 New-CimSession 或 Get-CimSession Cmdlet 的輸出。預設為本機電腦上的目前工作階段。
別名 |
Session |
必要? |
false |
位置? |
named |
預設值 |
無 |
接受管線輸入? |
false |
接受萬用字元? |
false |
-FriendlyName<String[]>
Gets the disk with the specified friendly name. Enter a friendly name, or use wildcard characters to enter a name pattern.
別名 |
無 |
必要? |
false |
位置? |
named |
預設值 |
無 |
接受管線輸入? |
false |
接受萬用字元? |
false |
-Number<UInt32[]>
Specifies the disk number for which to get the associated Disk object.
別名 |
DeviceId |
必要? |
false |
位置? |
1 |
預設值 |
無 |
接受管線輸入? |
True (ByPropertyName) |
接受萬用字元? |
false |
-Partition<CimInstance>
Accepts a Partition object as input. The Partition CIM object is exposed by the Get-Partition cmdlet.
別名 |
無 |
必要? |
false |
位置? |
named |
預設值 |
無 |
接受管線輸入? |
True (ByValue) |
接受萬用字元? |
false |
-Path<String[]>
Contains valid path information.
別名 |
無 |
必要? |
false |
位置? |
named |
預設值 |
無 |
接受管線輸入? |
True (ByPropertyName) |
接受萬用字元? |
false |
-ThrottleLimit<Int32>
指定為執行此 Cmdlet 可建立的最大同時作業數。如果省略這個參數或輸入 0
的值,則 Windows PowerShell® 會根據在電腦上執行的 CIM Cmdlet 數目,計算 Cmdlet 的最佳節流限制。節流限制僅適用於目前 Cmdlet,不適用於工作階段或電腦。
別名 |
無 |
必要? |
false |
位置? |
named |
預設值 |
無 |
接受管線輸入? |
false |
接受萬用字元? |
false |
-UniqueId<String[]>
Gets only the disks with the specified IDs. Type one or more IDs (separated by commas).
別名 |
Id |
必要? |
false |
位置? |
named |
預設值 |
無 |
接受管線輸入? |
false |
接受萬用字元? |
false |
-VirtualDisk<CimInstance>
Accepts a VirtualDisk object as input. The Virtual Disk CIM object is exposed by the Get-VirtualDisk cmdlet.
別名 |
無 |
必要? |
false |
位置? |
named |
預設值 |
無 |
接受管線輸入? |
True (ByValue) |
接受萬用字元? |
false |
-iSCSIConnection<CimInstance>
Accepts an iSCSIConnection object as input. The iSCSI Connection CIM object is exposed by the Get-IscsiConnection cmdlet.
別名 |
無 |
必要? |
false |
位置? |
named |
預設值 |
無 |
接受管線輸入? |
True (ByValue) |
接受萬用字元? |
false |
-iSCSISession<CimInstance>
Accepts an iSCSISession object as input. The iSCSI Session CIM object is exposed by the Get-IscsiSession cmdlet.
別名 |
無 |
必要? |
false |
位置? |
named |
預設值 |
無 |
接受管線輸入? |
True (ByValue) |
接受萬用字元? |
false |
<CommonParameters>
此 Cmdlet 支援一般參數:-Verbose、-Debug、-ErrorAction、-ErrorVariable、-OutBuffer 與 -OutVariable。如需詳細資訊,請參閱 about_CommonParameters (https://go.microsoft.com/fwlink/p/?LinkID=113216)。
輸入
輸入類型是您可以使用管線處理方式傳遞給 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 Partition 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.
輸出
輸出類型是 Cmdlet 所發出的物件類型。
Microsoft.Management.Infrastructure.CimInstance#ROOT/Microsoft/Windows/Storage/MSFT_Disk
This cmdlet outputs one or more objects representing disks.
附註
Microsoft.Management.Infrastructure.CimInstance
物件是一個包裝函式類別,可顯示 Windows Management Instrumentation (WMI) 物件。井字號 (#
) 後面的路徑會提供基礎 WMI 物件的命名空間和類別名稱。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.
範例
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