Partager via


Get-SCVirtualDiskDrive

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

Syntax

All

Get-SCVirtualDiskDrive
    [-VMMServer <ServerConnection>]
    [-All]
    [-OnBehalfOfUser <String>]
    [-OnBehalfOfUserRole <UserRole>]
    [<CommonParameters>]

VM

Get-SCVirtualDiskDrive
    -VM <VM>
    [-VMMServer <ServerConnection>]
    [-OnBehalfOfUser <String>]
    [-OnBehalfOfUserRole <UserRole>]
    [<CommonParameters>]

Template

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

ID

Get-SCVirtualDiskDrive
    [-ID] <Guid>
    [-VMMServer <ServerConnection>]
    [-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.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

All
Position:Named
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:False
Value from remaining arguments:False

-ID

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

Parameter properties

Type:Guid
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

ID
Position:0
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:False
Value from remaining arguments:False

-OnBehalfOfUser

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

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments: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.

Parameter properties

Type:UserRole
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-VM

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

Parameter properties

Type:VM
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

VM
Position:Named
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:False
Value from remaining arguments:False

-VMMServer

Specifies a VMM server object.

Parameter properties

Type:ServerConnection
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:True
Value from pipeline by property name:False
Value from remaining arguments:False

-VMTemplate

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

Parameter properties

Type:Template
Default value:None
Supports wildcards:False
DontShow:False
Aliases:Template

Parameter sets

Template
Position:Named
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:False
Value from remaining arguments:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

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.