Partilhar via


Get-SCVirtualDiskDrive

Get-SCVirtualDiskDrive

Gets a virtual disk drive object on a virtual machine template or on a virtual machine managed by VMM.

Syntax

Parameter Set: All
Get-SCVirtualDiskDrive -All [-OnBehalfOfUser <System.String> ] [-OnBehalfOfUserRole <Microsoft.SystemCenter.VirtualMachineManager.UserRole> ] [-VMMServer <ServerConnection> ] [ <CommonParameters>]

Parameter Set: ID
Get-SCVirtualDiskDrive [-ID] <Guid> [-OnBehalfOfUser <System.String> ] [-OnBehalfOfUserRole <Microsoft.SystemCenter.VirtualMachineManager.UserRole> ] [-VMMServer <ServerConnection> ] [ <CommonParameters>]

Parameter Set: Template
Get-SCVirtualDiskDrive -VMTemplate <Template> [-OnBehalfOfUser <System.String> ] [-OnBehalfOfUserRole <Microsoft.SystemCenter.VirtualMachineManager.UserRole> ] [-VMMServer <ServerConnection> ] [ <CommonParameters>]

Parameter Set: VM
Get-SCVirtualDiskDrive -VM <VM> [-OnBehalfOfUser <System.String> ] [-OnBehalfOfUserRole <Microsoft.SystemCenter.VirtualMachineManager.UserRole> ] [-VMMServer <ServerConnection> ] [ <CommonParameters>]

Detailed Description

The Get-SCVirtualDiskDrive cmdlet gets one or more Virtual Machine Manager (VMM) virtual disk drive objects. These virtual disk drives can be configured on virtual machine templates stored in the library, or on virtual machines either deployed on a host or stored in the library.

Parameters

-All

Retrieves a full list of all subordinate objects independent of the parent object. For example, the command Get-SCVirtualDiskDrive -All retrieves all virtual disk drive objects regardless of the virtual machine object or template object that each virtual disk drive object is associated with.

Aliases

none

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

True (ByValue)

Accept Wildcard Characters?

false

-ID<Guid>

Specifies the numerical identifier as a globally unique identifier (GUID) for a specific object.

Aliases

none

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

True (ByValue)

Accept Wildcard Characters?

false

-OnBehalfOfUser<System.String>

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-OnBehalfOfUserRole<Microsoft.SystemCenter.VirtualMachineManager.UserRole>

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-VM<VM>

Specifies a virtual machine object.

Aliases

none

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

True (ByValue)

Accept Wildcard Characters?

false

-VMMServer<ServerConnection>

Specifies a VMM server object.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

True (ByValue)

Accept Wildcard Characters?

false

-VMTemplate<Template>

Specifies a VMM template object used to create virtual machines.

Aliases

Template

Required?

true

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 (https://go.microsoft.com/fwlink/p/?LinkID=113216).

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

Outputs

The output type is the type of the objects that the cmdlet emits.

  • VirtualDiskDrive

Notes

  • Requires a VMM virtual machine template object or a virtual machine object, which can be retrieved by using the Get-SCVMTemplate or Get-SCVirtualMachine cmdlets, respectively.

Examples

Example Example 1: Get a list of all available virtual disk drives in your VMM environment.

This command gets a list of all virtual disk drives bound to all virtual machines registered to VMM on VMMServer01. The command displays information about each virtual disk drive.

PS C:\> Get-SCVirtualDiskDrive -VMMServer "VMMServer01.Contoso.com" -All

Example 2: Get virtual disk drives for a specific virtual machine

The first command gets the virtual machine object named VM02, and then stores the object in the $VM variable.

The second command gets all virtual disk drive objects on VM02, and then stores the objects in $VirtDiskDrive. If, as this example assumes, a virtual machine contains multiple virtual disk drives, each virtual disk drive has connected to it either a virtual hard disk or a pass-through disk.

The last command displays the properties of each virtual disk drive on VM02, including the name of any virtual hard disks and the path to the physical drive on the host for any pass-through disks.

PS C:\> $VM = Get-SCVirtualMachine -VMMServer "VMMServer01.Contoso.com" | where {$_.Name -eq "VM02"}
PS C:\> $VirtDiskDrive = Get-SCVirtualDiskDrive -VM $VM
PS C:\> $VirtDiskDrive

Example Example 3:. Count all virtual disk drives, except pass-through disks, on the second slot for both IDE channels.:

The first command gets the virtual disk drive objects, excluding pass-through disks, that are connected to the second slot of either IDE channel. Using the @ symbol and parentheses ensures that the command stores the results in an array in case the command returns a single object or $Null.

The second command displays the number of virtual disk drive objects that match the filter criteria.

PS C:\> $VirtDiskDrive = @(Get-SCVirtualDiskDrive -All | where {$_.BusType -eq 'IDE' -and $_.PassThroughDisk -eq $null -and $_.LUN -eq 1 -and ($_.Bus -eq 0 -or $_.Bus -eq 1)})
PS C:\> $VirtDiskDrive.Count

Example 4: Get virtual disk drives for all virtual machine templates

The first command gets all virtual machine template objects, and then stores the objects in $Templates. Using the @ symbol and parentheses ensures that the command stores the results in an array in case the command returns a single object or $Null.

The second command passes each virtual machine template object stored in $Templates to the ForEach-Object cmdlet which gets all disk drive objects for each template. Then the command selects only those virtual disk drive objects with an IDE bus type and passes those objects to the Format-List cmdlet. That cmdlet displays the Name, Bus Type, Bus, and LUN for each virtual disk drive object.

For more information about the standard Windows PowerShell ForEach-Object cmdlet type: Get-Help ForEach-Object.

PS C:\> $Templates = @(Get-SCVMTemplate)
PS C:\> $Templates | ForEach-Object {Get-SCVirtualDiskDrive -Template $_ | where {$_.BusType -eq "IDE"}} | Format-List Name,BusType,Bus,LUN

Compress-SCVirtualDiskDrive

Convert-SCVirtualDiskDrive

Expand-SCVirtualDiskDrive

New-SCVirtualDiskDrive

Remove-SCVirtualDiskDrive

Set-SCVirtualDiskDrive