vSphere PowerCLI Cmdlets Reference

Get-HardDisk

Synopsis

Retrieves the virtual hard disks available on a vSphere server.

Syntax

Get-HardDisk [-Path <DatastoreItem[]>] [-DiskType <DiskType[]>] [-Server <VIServer[]>] [<CommonParameters>]
Get-HardDisk -Datastore <Datastore[]> [-DatastorePath <String[]>] [-DiskType <DiskType[]>] [-Server <VIServer[]>] [<CommonParameters>]
Get-HardDisk [-DiskType <DiskType[]>] [[-VM] <VirtualMachine[]>] [[-Template] <Template[]>] [[-Snapshot] <Snapshot[]>] [-Server <VIServer[]>] [<CommonParameters>]

Related Commands

Online version
Copy-HardDisk
New-HardDisk
Remove-HardDisk
Set-HardDisk

Detailed Description

Returns the virtual hard disks available on a vSphere server. You can retrieve a hard disk by specifying the virtual machines, templates, or snapshots to which it belongs. If the hard disk is attached to no virtual machines, templates, or snapshots, you can search for it in datastores or retrieve it by providing a datastore path to the file where the virtual hard disk is stored. In this case, you might not be able to derive disk type info, and the value of the DiskType property of the hard disk is Unknown.

Parameters

NameDescriptionRequired?Pipeline InputDefault Value
PathSpecify the file paths to the virtual hard disks you want to retrieve. The cmdlet searches recursively the specified locations.falsefalseIf in a datastore provider ? the current path, else - null.
DiskTypeSpecify the type of the hard disks you want to retrieve. The valid values are rawVirtual, rawPhysical, flat, and unknown. If the hard disk is attached to no virtual machines, templates, or snapshots, you can retrieve it by providing a datastore path to the file where the virtual hard disk is stored. In this case, you might not be able to derive disk type info, and the value of the DiskType property of the hard disk is Unknown.falsefalse
ServerSpecify the vSphere servers on which you want to run the cmdlet. If no value is given to this parameter, the command runs on the default servers. For more information about default servers, see the description of Connect-VIServer.falsefalse
DatastoreSpecify the datastores you want to search for hard disks. This parameter is required when retrieving a hard disk that is attached to no virtual machines, templates, or snapshots.falsetrue (ByValue)
DatastorePathSpecify datastore paths to the hard disks you want to retrieve. The paths must be in the following format: [datastore_name] <file_path>, where [datastore_name] is the name of the datastore in square brackets and <file_path> is a slash-delimited path from the root of the datastore to the virtual hard disk file.
The cmdlet searches recursively the specified locations.

To learn more about the Datastore Provider, in the vSphere PowerCLI service console,type:

help about_vimdatastore
falsefalseIf working in the datastore provider - the current path, else - &null.
VMSpecify the virtual machines from which you want to retrieve the hard disks.falsetrue (ByValue)
TemplateSpecify the virtual machine templates from which you want to retrieve the hard disks.falsetrue (ByValue)
SnapshotSpecify the snapshots from which you want to retrieve the hard disks.falsetrue (ByValue)

Return Type

HardDisk

Notes

Examples

-------------- Example 1 --------------

Get-HardDisk -VM VM

Retrieves the hard disks of the virtual machine named VM.

-------------- Example 2 --------------

Get-HardDisk -VM $vm -DiskType flat

Retrieves the flat hard disks from the specified virtual machines.

-------------- Example 3 --------------

Get-HardDisk -Datastore "Storage1" -DatastorePath "[Storage1] myVM/"

Retrieves the hard disks from the specified datastore and from the specified datastore path.


Copyright © 1998 - 2010 VMware, Inc. All rights reserved.