This example gets a SCSI controller on a virtual machine named Test and then adds physical disk 2 to that controller.
Example 4
PS C:\> Get-Disk 2 | Add-VMHardDiskDrive -VMName Test
This example gets physical disk 2 and then adds it to a virtual machine named Test.
Parameters
-AllowUnverifiedPaths
Specifies that no error is to be thrown if the specified path is not verified as accessible by the cluster.
This parameter is applicable to clustered virtual machines.
Parameter properties
Type:
SwitchParameter
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
-CimSession
Runs the cmdlet in a remote session or on a remote computer.
Enter a computer name or a session object, such as the output of a New-CimSession or Get-CimSession cmdlet.
The default is the current session on the local computer.
Parameter properties
Type:
CimSession[]
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
VMName
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-ComputerName
Specifies one or more Hyper-V hosts that run this cmdlet.
NetBIOS names, IP addresses, and fully qualified domain names are allowable.
The default is the local computer.
Use localhost or a dot (.) to specify the local computer explicitly.
Parameter properties
Type:
String[]
Default value:
None
Supports wildcards:
False
DontShow:
False
Aliases:
PSComputerName
Parameter sets
VMName
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-Confirm
Prompts you for confirmation before running the cmdlet.
Parameter properties
Type:
SwitchParameter
Default value:
False
Supports wildcards:
False
DontShow:
False
Aliases:
cf
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-ControllerLocation
Specifies the number of the location on the controller at which the hard disk drive is to be added.
If not specified, the first available location in the controller specified with the ControllerNumber parameter is used.
Parameter properties
Type:
Int32
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
(All)
Position:
3
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-ControllerNumber
Specifies the number of the controller to which the hard disk drive is to be added.
If not specified, this parameter assumes the value of the first available controller at the location specified in the ControllerLocation parameter.
Parameter properties
Type:
Int32
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
VMName
Position:
2
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
VMObject
Position:
2
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-ControllerType
Specifies the type of the controller to which the hard disk drive is to be added.
If not specified, IDE is attempted first.
If the IDE controller port at the specified number and location is already connected to a drive, then it will try to create one on the SCSI controller specified by ControllerNumber.
Allowed values are IDE and SCSI.
Parameter properties
Type:
ControllerType
Default value:
None
Accepted values:
IDE, SCSI
Supports wildcards:
False
DontShow:
False
Parameter sets
VMName
Position:
1
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
VMObject
Position:
1
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-Credential
Specifies one or more user accounts that have permission to perform this action.
The default is the current user.
Parameter properties
Type:
PSCredential[]
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
VMName
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-DiskNumber
Specifies the disk number of the offline physical hard drive to be connected as a passthrough disk.
Parameter properties
Type:
UInt32
Default value:
None
Supports wildcards:
False
DontShow:
False
Aliases:
Number
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
True
Value from remaining arguments:
False
-MaximumIOPS
Specifies the maximum normalized I/O operations per second (IOPS) for the hard disk.
Hyper-V calculates normalized IOPS as the total size of I/O per second divided by 8 KB.
Parameter properties
Type:
UInt64
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
-MinimumIOPS
Specifies the minimum normalized I/O operations per second (IOPS) for the hard disk.
Hyper-V calculates normalized IOPS as the total size of I/O per second divided by 8 KB.
Parameter properties
Type:
UInt64
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
-OverrideCacheAttributes
The Add-VMHardDiskDrive cmdlet adds a hard disk drive to a virtual machine.
Passes the added Microsoft.HyperV.PowerShell.HardDiskDrive object through to the pipeline.
Parameter properties
Type:
SwitchParameter
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
-Path
Specifies the full path of the hard disk drive file to be added.
Parameter properties
Type:
String
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
(All)
Position:
4
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-QoSPolicy
Specifies the name of the storage Quality of Service (QoS) policy that this cmdlet associates with the hard disk drive.
Parameter properties
Type:
CimInstance
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
-QoSPolicyID
Specifies the unique ID for a storage QoS policy that this cmdlet associates with the hard disk drive.
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
-ResourcePoolName
Specifies the friendly name of the ISO resource pool to which this virtual hard disk is to be associated.
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
-SupportPersistentReservations
Indicates that the hard disk supports SCSI persistent reservation semantics.
Specify this parameter when the hard disk is a shared disk that is used by multiple virtual machines.
Parameter properties
Type:
SwitchParameter
Default value:
None
Supports wildcards:
False
DontShow:
False
Aliases:
ShareVirtualDisk
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 the virtual machine to which the hard disk drive is to be added.
Parameter properties
Type:
VirtualMachine[]
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
VMObject
Position:
0
Mandatory:
True
Value from pipeline:
True
Value from pipeline by property name:
False
Value from remaining arguments:
False
-VMDriveController
Specifies the controller to which the hard disk drive is to be added.
Parameter properties
Type:
VMDriveController
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
VMDriveController
Position:
0
Mandatory:
True
Value from pipeline:
True
Value from pipeline by property name:
False
Value from remaining arguments:
False
-VMName
Specifies the name of the virtual machine to which the hard disk drive is to be added.
Parameter properties
Type:
String[]
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
VMName
Position:
0
Mandatory:
True
Value from pipeline:
True
Value from pipeline by property name:
False
Value from remaining arguments:
False
-WhatIf
Shows what would happen if the cmdlet runs.
The cmdlet is not run.
Parameter properties
Type:
SwitchParameter
Default value:
False
Supports wildcards:
False
DontShow:
False
Aliases:
wi
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
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.