Freigeben über


Get-SCVirtualDiskDrive

Gets virtual disk drives on a virtual machine template or on a virtual machine.

Syntax

Get-SCVirtualDiskDrive
   [-VMMServer <ServerConnection>]
   [-All]
   [-OnBehalfOfUser <String>]
   [-OnBehalfOfUserRole <UserRole>]
   [<CommonParameters>]
Get-SCVirtualDiskDrive
   [-VMMServer <ServerConnection>]
   -VM <VM>
   [-OnBehalfOfUser <String>]
   [-OnBehalfOfUserRole <UserRole>]
   [<CommonParameters>]
Get-SCVirtualDiskDrive
   [-VMMServer <ServerConnection>]
   -VMTemplate <Template>
   [-OnBehalfOfUser <String>]
   [-OnBehalfOfUserRole <UserRole>]
   [<CommonParameters>]
Get-SCVirtualDiskDrive
   [-VMMServer <ServerConnection>]
   [-ID] <Guid>
   [-OnBehalfOfUser <String>]
   [-OnBehalfOfUserRole <UserRole>]
   [<CommonParameters>]

Description

The Get-SCVirtualDiskDrive cmdlet gets 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.

Examples

Example 1: Get all virtual disk drives in your VMM environment

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

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

Example 2: Get virtual disk drives for a virtual machine

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

The first command gets the virtual machine object named VM02 by using the Get-SCVirtualMachine cmdlet. The command stores that object in the $VM variable.

The second command gets all virtual disk drive objects on VM02, and stores those 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. This information includes the name of any virtual hard disks and the path of the physical drive on the host for any pass-through disks.

Example 3: Count virtual disk drives, except pass-through disks

PS C:\> $VirtDiskDrive = @(Get-SCVirtualDiskDrive -All | Where-Object {$_.BusType -Eq "IDE" -And $_.PassThroughDisk -Eq $Null -And $_.LUN -Eq 1 -And ($_.Bus -Eq 0 -Or $_.Bus -Eq 1)})
PS C:\> $VirtDiskDrive.Count

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

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

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

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

The first command gets all virtual machine templates, and then stores those objects in the $Templates array.

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

Parameters

-All

Indicates that this cmdlet retrieves a full list of all virtual disk drive objects independent of the parent object.

Type:SwitchParameter
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-ID

Specifies the unique ID of the virtual disk drive that this cmdlet gets.

Type:Guid
Position:0
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-OnBehalfOfUser

Specifies a user name. This cmdlet operates on behalf of the user that this parameter specifies.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-OnBehalfOfUserRole

Specifies a user role. To obtain a user role, use the Get-SCUserRole cmdlet. This cmdlet operates on behalf of the user role that this parameter specifies.

Type:UserRole
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-VM

Specifies a virtual machine object from which this cmdlet gets virtual disk drives.

Type:VM
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-VMMServer

Specifies a VMM server object.

Type:ServerConnection
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-VMTemplate

Specifies a VMM template object that is used to create virtual machines that contain virtual disk drives that this cmdlet gets.

Type:Template
Aliases:Template
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

Outputs

VirtualDiskDrive

This cmdlet returns a VirtualDiskDrive object.

Notes

  • This cmdlet requires a VMM virtual machine template object or a virtual machine object, which can be retrieved by using the Get-SCVMTemplate cmdlet or the Get-SCVirtualMachine cmdlet.