Get-SCVirtualDiskDrive

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

Description

The Get-SCVirtualDiskDrive cmdlet gets one or more System Center 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. 

For more information about Get-SCVirtualDiskDrive, type: "Get-Help Get-SCVirtualDiskDrive -online".

Parameters

All

Required? true
Accept Pipeline Input? true (ByValue)
Position? named
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.

VMMServer

Required? false
Accept Pipeline Input? true (ByValue)
Position? named
Specifies a VMM server object.

VMTemplate

Required? true
Accept Pipeline Input? true (ByValue)
Position? named
Specifies a VMM template object used to create virtual machines.

VMMServer

Required? false
Accept Pipeline Input? true (ByValue)
Position? named
Specifies a VMM server object.

VM

Required? true
Accept Pipeline Input? true (ByValue)
Position? named
Specifies a virtual machine object.

VMMServer

Required? false
Accept Pipeline Input? true (ByValue)
Position? named
Specifies a VMM server object.
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

1: Get a list of all available virtual disk drives in your VMM environment.
PS C:\> Get-SCVirtualDiskDrive -VMMServer "VMMServer01.Contoso.com" -All
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 to the user.
2: Get virtual disk drives for a specific virtual machine.
PS C:\> $VM = Get-SCVirtualMachine -VMMServer "VMMServer01.Contoso.com" | where {$_.Name -eq "VM02"} 
PS C:\> $VirtDiskDrive = Get-SCVirtualDiskDrive -VM $VM
PS C:\> $VirtDiskDrive
The first command gets the virtual machine object named VM02 and stores the object in the $VM variable.

The second command gets all virtual disk drive objects on VM02 and 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 to the user, including the name of any virtual hard disks and the path to the physical drive on the host for any pass-through disks.  
3. Count all virtual disk drives, except pass-through disks, on the second slot for both IDE channels.
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
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 a null value.

The second displays the number of virtual disk drive objects that match the filter criteria.
4: Get virtual disk drives for all virtual machine templates.
PS C:\> $Templates = @(Get-SCVMTemplate)
PS C:\> $Templates | ForEach {Get-SCVirtualDiskDrive -Template $_ | where {$_.BusType -eq "IDE"}} | Format-List Name,BusType,Bus,LUN
The first command gets all virtual machine template objects and 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 a null value.

The second command passes each virtual machine template object stored in $Templates to the ForEach 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 which displays the Name, Bus Type, Bus, and LUN for each virtual disk drive object.

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

See Also