@@ -12,7 +12,7 @@ ai-usage: ai-generated
1212
1313## Synopsis
1414
15- Attaches a Storage Spaces Direct virtual disk to a virtual machine.
15+ Directly attaches a Storage Spaces Direct virtual disk to a virtual machine.
1616
1717## Syntax
1818
@@ -41,13 +41,26 @@ Add-VMDirectVirtualDisk [-VMDriveController] <VMDriveController> [-ControllerLoc
4141
4242## Description
4343
44- The ** Add-VMDirectVirtualDisk** cmdlet attaches a Storage Spaces Direct virtual disk to a virtual
45- machine. This enables high-performance storage configurations by directly connecting the virtual
46- disk to the VM.
44+ The ** Add-VMDirectVirtualDisk** cmdlet directly attaches a Storage Spaces Direct virtual disk to a
45+ virtual machine. This enables high-performance storage configurations by directly connecting the
46+ virtual disk to the VM.
4747
4848## Examples
4949
50- ### Example 1: Attach a virtual disk by specifying VM name and controller details
50+ ### Example 1: Attach a virtual disk by using a virtual disk object
51+
52+ This example gets the Storage Spaces Direct virtual disk object named ` Volume01 ` and the VM object
53+ named ` VM1 ` on ` Cluster01 ` , and then directly attaches the disk to the VM, using the first available
54+ controller and controller location.
55+
56+ ``` powershell
57+ $VirtualDisk = Get-VirtualDisk -FriendlyName "Volume01" -CimSession "Cluster01"
58+ $vm = Get-VM -Name "VM1" -CimSession "Cluster01"
59+
60+ Add-VMDirectVirtualDisk -VM $vm -VirtualDiskUniqueId $VirtualDisk.UniqueId
61+ ```
62+
63+ ### Example 2: Attach a virtual disk by specifying VM name and controller details
5164
5265This example attaches the virtual disk with the unique ID ` 111BBE22FD037E4EB87F366648FBF111 ` to the
5366virtual machine named ` VM1 ` at controller 0, location 1.
@@ -64,25 +77,27 @@ $parameters = @{
6477Add-VMDirectVirtualDisk @parameters
6578```
6679
67- ### Example 2 : Attach a virtual disk by using a virtual disk object
80+ ### Example 3 : Attach multiple virtual disks to a VM
6881
69- This example gets the Storage Spaces Direct virtual disk object named ` Volume01 ` and the VM object
70- named ` VM1 ` , and then directly attaches the disk to the VM .
82+ This example retrieves all virtual disks with names starting with ` Volume0 ` from the cluster named
83+ ` Cluster01 ` and attaches them to the virtual machine named ` VM1 ` .
7184
7285``` powershell
73- $virtualDisk = Get-VirtualDisk -Friendlyname "Volume01 "
74- $vm = Get-VM -Name "VM1"
86+ $VirtualDisks = Get-VirtualDisk -FriendlyName "Volume0*" -CimSession "Cluster01 "
87+ $vm = Get-VM -Name "VM1" -CimSession "Cluster01"
7588
76- Add-VMDirectVirtualDisk -VM $vm -VirtualDiskUniqueId $virtualDisk.UniqueId
89+ foreach ($diskID in $virtualdisks) {
90+ Add-VMDirectVirtualDisk -VM $vm -VirtualDiskUniqueId $diskID.UniqueID
91+ }
7792```
7893
7994## Parameters
8095
8196### -CimSession
8297
83- Runs the command using the specified CIM session. Enter a variable that contains the CIM session , or
84- a command that creates or gets the CIM session, such as ` New-CimSession ` or ` Get-CimSession ` . For more
85- information, see
98+ Runs the cmdlet in a remote session or on a remote computer. Enter a computer name, cluster name , or
99+ a session object, such as the output of a ` New-CimSession ` or ` Get-CimSession ` cmdlet. The default
100+ is the current session on the local computer. For more information, see
86101[ about_CimSession] ( /powershell/module/microsoft.powershell.core/about/about_cimsession ) .
87102
88103``` yaml
@@ -99,7 +114,8 @@ Accept wildcard characters: False
99114
100115### -ControllerLocation
101116
102- Specifies the location on the controller where the virtual disk will be attached.
117+ Specifies the location on the controller where the virtual disk will be attached. If you don't
118+ specify a controller location, the cmdlet uses the first available location.
103119
104120` ` ` yaml
105121Type : System.Int32
@@ -115,7 +131,8 @@ Accept wildcard characters: False
115131
116132### -ControllerNumber
117133
118- Specifies the number of the controller where the virtual disk will be attached.
134+ Specifies the number of the controller where the virtual disk will be attached. If you don't specify
135+ a controller number, the cmdlet uses the first available controller.
119136
120137` ` ` yaml
121138Type : System.Int32
@@ -131,7 +148,8 @@ Accept wildcard characters: False
131148
132149### -ControllerType
133150
134- Specifies the type of controller. Only SCSI is supported.
151+ Specifies the type of controller used by the VM. If you don't specify a controller type, the cmdlet
152+ uses the SCSI controller type, which is the only type supported at this time.
135153
136154` ` ` yaml
137155Type : ControllerType
@@ -148,7 +166,8 @@ Accept wildcard characters: False
148166
149167### -VirtualDiskUniqueId
150168
151- Specifies the unique ID of the virtual disk to attach.
169+ Specifies the unique ID of the Storage Spaces virtual disk to attach. For example,
170+ ` 111BBE22-FD03-7E4E-B87F-366648FBF111`.
152171
153172` ` ` yaml
154173Type: System.String
@@ -164,7 +183,7 @@ Accept wildcard characters: False
164183
165184# ## -VM
166185
167- Specifies the virtual machine object to which the virtual disk will be attached.
186+ Specifies a virtual machine object to which the virtual disk will be attached.
168187
169188` ` ` yaml
170189Type: Microsoft.HyperV.PowerShell.VirtualMachine[]
@@ -221,21 +240,24 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
221240
222241# ## System.String[]
223242
224- Specifies the names of virtual machines .
243+ Specifies the name of a virtual machine .
225244
226245# ## Microsoft.HyperV.PowerShell.VirtualMachine[]
227246
228- Specifies virtual machine objects.
247+ Specifies a virtual machine object to which the virtual disk will be attached. You can use the
248+ [Get-VM](/powershell/module/hyper-v/get-vm) cmdlet to get the virtual machine object.
229249
230250# ## Microsoft.HyperV.PowerShell.VMDriveController
231251
232- Specifies drive controller objects.
252+ Specifies a drive controller object to which the virtual disk will be attached. You can use
253+ the [Get-VmScsiController](/powershell/module/hyper-v/get-vmscsicontroller) cmdlet to get the drive
254+ controller object.
233255
234256# # Outputs
235257
236- ### System.Object
258+ # ## None
237259
238- Returns an object representing the result of the operation .
260+ This cmdlet returns no output of its own .
239261
240262# # Notes
241263
0 commit comments