< Back

Get-HardDisk

Sun Jan 19, 2020 6:50 pm

NAME Get-HardDisk



SYNOPSIS

This cmdlet retrieves the virtual hard disks available on a vCenter Server system.





SYNTAX

Get-HardDisk -Datastore <Datastore[]> [-DatastorePath <String[]>] [-DiskType <DiskType[]>] [-Id <String[]>]

[-Server <VIServer[]>] [<CommonParameters>]



Get-HardDisk [-DiskType <DiskType[]>] [-Id <String[]>] [-Path <DatastoreItem[]>] [-Server <VIServer[]>]

[<CommonParameters>]



Get-HardDisk [[-VM] <VirtualMachine[]>] [[-Template] <Template[]>] [[-Snapshot] <Snapshot[]>] [-DiskType

<DiskType[]>] [-Id <String[]>] [-Name <String[]>] [-Server <VIServer[]>] [<CommonParameters>]



Get-HardDisk -RelatedObject <HardDiskRelatedObjectBase[]> [<CommonParameters>]





DESCRIPTION

This cmdlet returns the virtual hard disks available on a vCenter Server system. You can retrieve a hard disk by

specifying the virtual machines, templates, or snapshots to which it belongs. If the hard disk is not attached to

any 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

-Datastore <Datastore[]>

Specifies the datastores or datastore clusters 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.



Required? true

Position? named

Default value None

Accept pipeline input? True (ByValue)

Accept wildcard characters? true



-DatastorePath <String[]>

Specifies 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 VMware PowerCLI service console, type:



help about_vimdatastore



Required? false

Position? named

Default value If working in the datastore provider - the current path, else - &null.

Accept pipeline input? False

Accept wildcard characters? true



-DiskType <DiskType[]>

Specifies the type of the hard disks you want to retrieve. The valid values are rawVirtual, rawPhysical, flat,

and unknown. If the hard disk is not attached to any 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.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-Id <String[]>

Specifies the IDs of the hard disks you want to retrieve.



Note: When a list of values is specified for the Id parameter, the returned objects would have an ID that

matches exactly one of the string values in that list.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? true



-Name <String[]>

Specifies the names of the SCSI hard disks you want to retrieve.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? true



-Path <DatastoreItem[]>

Specifies the file paths to the virtual hard disks you want to retrieve. The cmdlet searches recursively the

specified locations.



Required? false

Position? named

Default value If in a datastore provider - the current path, else - null.

Accept pipeline input? False

Accept wildcard characters? true



-RelatedObject <HardDiskRelatedObjectBase[]>

Specifies objects to retrieve one or more HardDisk objects that are related to them.



Required? true

Position? named

Default value None

Accept pipeline input? True (ByValue)

Accept wildcard characters? false



-Server <VIServer[]>

Specifies the vCenter Server systems on which you want to run the cmdlet. If no value is passed to this

parameter, the command runs on the default servers. For more information about default servers, see the

description of Connect-VIServer.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? true



-Snapshot <Snapshot[]>

Specifies the snapshots from which you want to retrieve the hard disks.



Required? false

Position? 3

Default value None

Accept pipeline input? True (ByValue)

Accept wildcard characters? false



-Template <Template[]>

Specifies the virtual machine templates from which you want to retrieve the hard disks.



Required? false

Position? 2

Default value None

Accept pipeline input? True (ByValue)

Accept wildcard characters? true



-VM <VirtualMachine[]>

Specifies the virtual machines from which you want to retrieve the hard disks.



Required? false

Position? 1

Default value None

Accept pipeline input? True (ByValue)

Accept wildcard characters? true



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS

Zero or more HardDisk objects







NOTES









-------------------------- 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.



RELATED LINKS

Online Version: https://code.vmware.com/doc/preview?id= ... dDisk.html

Copy-HardDisk

New-HardDisk

Remove-HardDisk

Set-HardDisk

Move-HardDisk