|
| 1 | +--- |
| 2 | +description: Assigns a device to a virtual machine. |
| 3 | +external help file: Microsoft.HyperV.PowerShell.Cmdlets.dll-Help.xml |
| 4 | +Module Name: Hyper-V |
| 5 | +ms.date: 06/12/2024 |
| 6 | +online version: https://learn.microsoft.com/powershell/module/hyper-v/add-vmassignabledevice?view=windowsserver2025-ps&wt.mc_id=ps-gethelp |
| 7 | +schema: 2.0.0 |
| 8 | +title: Add-VMAssignableDevice |
| 9 | +--- |
| 10 | + |
| 11 | +# Add-VMAssignableDevice |
| 12 | + |
| 13 | +## SYNOPSIS |
| 14 | +Adds an assignable device to a specific virtual machine. |
| 15 | + |
| 16 | +## SYNTAX |
| 17 | + |
| 18 | +### VMName (Default) |
| 19 | + |
| 20 | +``` |
| 21 | +Add-VMAssignableDevice [-CimSession <CimSession[]>] [-ComputerName <String[]>] |
| 22 | + [-Credential <PSCredential[]>] [-VMName] <String[]> [-InstancePath <String>] |
| 23 | + [-LocationPath <String>] [-VirtualFunction <UInt16>] [-ResourcePoolName <String>] [-Passthru] |
| 24 | + [-WhatIf] [-Confirm] [<CommonParameters>] |
| 25 | +``` |
| 26 | + |
| 27 | +### VMObject |
| 28 | + |
| 29 | +``` |
| 30 | +Add-VMAssignableDevice [-VM] <VirtualMachine[]> [-InstancePath <String>] [-LocationPath <String>] |
| 31 | + [-VirtualFunction <UInt16>] [-ResourcePoolName <String>] [-Passthru] [-WhatIf] [-Confirm] |
| 32 | + [<CommonParameters>] |
| 33 | +``` |
| 34 | + |
| 35 | +## DESCRIPTION |
| 36 | + |
| 37 | +The `Add-VMAssignableDevice` cmdlet assigns a physical device to a specified virtual machine (VM). |
| 38 | +This is commonly used for tasks such as attaching GPUs or network adapters directly to a VM to |
| 39 | +enhance performance for specific applications or workloads. The device can be specified through its |
| 40 | +instance path, location path, or assignable device object. |
| 41 | + |
| 42 | +## EXAMPLES |
| 43 | + |
| 44 | +### Example 1 |
| 45 | + |
| 46 | +```powershell |
| 47 | +Add-VMAssignableDevice -VMName "MyVM" -InstancePath "PCIROOT(0)#PCI(0300)#PCI(0000)" |
| 48 | +``` |
| 49 | + |
| 50 | +This example attaches a physical device, identified by its instance path, to the virtual machine |
| 51 | +named **MyVM**. |
| 52 | + |
| 53 | +### Example 2 |
| 54 | + |
| 55 | +```powershell |
| 56 | +$gpu = Get-VMHostAssignableDevice |
| 57 | +Add-VMHostAssignableDevice -HostAssignableDevice $gpu -ResourcePoolName "GpuChildPool" |
| 58 | +``` |
| 59 | + |
| 60 | +This example retrieves a list of GPUs or other assignable devices and adds these devices to a |
| 61 | +resource pool named **GpuChildPool**, making the devices available for use by virtual machines in |
| 62 | +that resource pool. |
| 63 | + |
| 64 | +## PARAMETERS |
| 65 | + |
| 66 | +### -CimSession |
| 67 | + |
| 68 | +Runs the cmdlet in a remote session or on a remote computer. Enter a computer name or a session |
| 69 | +object, such as the output of a [New-CimSession](/powershell/module/cimcmdlets/new-cimsession) |
| 70 | +or [Get-CimSession](/powershell/module/cimcmdlets/get-cimsession) cmdlet. The default is the |
| 71 | +current session on the local computer. |
| 72 | + |
| 73 | +```yaml |
| 74 | +Type: CimSession[] |
| 75 | +Parameter Sets: VMName |
| 76 | +Aliases: |
| 77 | + |
| 78 | +Required: False |
| 79 | +Position: Named |
| 80 | +Default value: None |
| 81 | +Accept pipeline input: False |
| 82 | +Accept wildcard characters: False |
| 83 | +``` |
| 84 | +
|
| 85 | +### -ComputerName |
| 86 | +
|
| 87 | +Specifies one or more Hyper-V hosts on which the assignable devices are to be retrieved. NetBIOS |
| 88 | +names, IP addresses, and fully qualified domain names are allowed. The default is the local |
| 89 | +computer. Use localhost or a dot (`.`) to specify the local computer explicitly. |
| 90 | + |
| 91 | +```yaml |
| 92 | +Type: String[] |
| 93 | +Parameter Sets: VMName |
| 94 | +Aliases: |
| 95 | +
|
| 96 | +Required: False |
| 97 | +Position: Named |
| 98 | +Default value: None |
| 99 | +Accept pipeline input: False |
| 100 | +Accept wildcard characters: False |
| 101 | +``` |
| 102 | + |
| 103 | +### -Credential |
| 104 | + |
| 105 | +Specifies one or more user accounts that have permission to perform this action. The default is the |
| 106 | +current user. |
| 107 | + |
| 108 | +```yaml |
| 109 | +Type: PSCredential[] |
| 110 | +Parameter Sets: VMName |
| 111 | +Aliases: |
| 112 | +
|
| 113 | +Required: False |
| 114 | +Position: Named |
| 115 | +Default value: None |
| 116 | +Accept pipeline input: False |
| 117 | +Accept wildcard characters: False |
| 118 | +``` |
| 119 | + |
| 120 | +### -InstancePath |
| 121 | + |
| 122 | +Represents the Device Instance path in the host machine. |
| 123 | + |
| 124 | +```yaml |
| 125 | +Type: String |
| 126 | +Parameter Sets: (All) |
| 127 | +Aliases: |
| 128 | +
|
| 129 | +Required: False |
| 130 | +Position: Named |
| 131 | +Default value: None |
| 132 | +Accept pipeline input: False |
| 133 | +Accept wildcard characters: False |
| 134 | +``` |
| 135 | + |
| 136 | +### -LocationPath |
| 137 | + |
| 138 | +Specifies the location path to the assignable device |
| 139 | + |
| 140 | +```yaml |
| 141 | +Type: String |
| 142 | +Parameter Sets: (All) |
| 143 | +Aliases: |
| 144 | +
|
| 145 | +Required: False |
| 146 | +Position: Named |
| 147 | +Default value: None |
| 148 | +Accept pipeline input: False |
| 149 | +Accept wildcard characters: False |
| 150 | +``` |
| 151 | + |
| 152 | +### -Passthru |
| 153 | + |
| 154 | +Returns an object for each process that the cmdlet started. |
| 155 | + |
| 156 | +```yaml |
| 157 | +Type: SwitchParameter |
| 158 | +Parameter Sets: (All) |
| 159 | +Aliases: |
| 160 | +
|
| 161 | +Required: False |
| 162 | +Position: Named |
| 163 | +Default value: None |
| 164 | +Accept pipeline input: False |
| 165 | +Accept wildcard characters: False |
| 166 | +``` |
| 167 | + |
| 168 | +### -ResourcePoolName |
| 169 | + |
| 170 | +Specifies the name of the resource pool to which the device is to be assigned. |
| 171 | + |
| 172 | +```yaml |
| 173 | +Type: String |
| 174 | +Parameter Sets: (All) |
| 175 | +Aliases: |
| 176 | +
|
| 177 | +Required: False |
| 178 | +Position: Named |
| 179 | +Default value: None |
| 180 | +Accept pipeline input: False |
| 181 | +Accept wildcard characters: False |
| 182 | +``` |
| 183 | + |
| 184 | +### -VirtualFunction |
| 185 | + |
| 186 | +Specifies the number of the virtual function (VF) of an SR-IOV-capable network adapter assigned to |
| 187 | +the virtual machine. |
| 188 | + |
| 189 | +```yaml |
| 190 | +Type: UInt16 |
| 191 | +Parameter Sets: (All) |
| 192 | +Aliases: |
| 193 | +
|
| 194 | +Required: False |
| 195 | +Position: Named |
| 196 | +Default value: None |
| 197 | +Accept pipeline input: False |
| 198 | +Accept wildcard characters: False |
| 199 | +``` |
| 200 | + |
| 201 | +### -VM |
| 202 | + |
| 203 | +Specifies the virtual machine to which the device is to be assigned. |
| 204 | + |
| 205 | +```yaml |
| 206 | +Type: VirtualMachine[] |
| 207 | +Parameter Sets: VMObject |
| 208 | +Aliases: |
| 209 | +
|
| 210 | +Required: True |
| 211 | +Position: 0 |
| 212 | +Default value: None |
| 213 | +Accept pipeline input: True (ByValue) |
| 214 | +Accept wildcard characters: False |
| 215 | +``` |
| 216 | + |
| 217 | +### -VMName |
| 218 | + |
| 219 | +Specifies the name of the virtual machine to which the device is to be assigned. |
| 220 | + |
| 221 | +```yaml |
| 222 | +Type: String[] |
| 223 | +Parameter Sets: VMName |
| 224 | +Aliases: |
| 225 | +
|
| 226 | +Required: True |
| 227 | +Position: 0 |
| 228 | +Default value: None |
| 229 | +Accept pipeline input: False |
| 230 | +Accept wildcard characters: False |
| 231 | +``` |
| 232 | + |
| 233 | +### -Confirm |
| 234 | + |
| 235 | +Prompts you for confirmation before running the cmdlet. |
| 236 | + |
| 237 | +```yaml |
| 238 | +Type: SwitchParameter |
| 239 | +Parameter Sets: (All) |
| 240 | +Aliases: cf |
| 241 | +
|
| 242 | +Required: False |
| 243 | +Position: Named |
| 244 | +Default value: None |
| 245 | +Accept pipeline input: False |
| 246 | +Accept wildcard characters: False |
| 247 | +``` |
| 248 | + |
| 249 | +### -WhatIf |
| 250 | + |
| 251 | +Shows what would happen if the cmdlet runs. The cmdlet is not run. |
| 252 | + |
| 253 | +```yaml |
| 254 | +Type: SwitchParameter |
| 255 | +Parameter Sets: (All) |
| 256 | +Aliases: wi |
| 257 | +
|
| 258 | +Required: False |
| 259 | +Position: Named |
| 260 | +Default value: None |
| 261 | +Accept pipeline input: False |
| 262 | +Accept wildcard characters: False |
| 263 | +``` |
| 264 | + |
| 265 | +### CommonParameters |
| 266 | + |
| 267 | +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, |
| 268 | +-InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, |
| 269 | +-WarningAction, and -WarningVariable. For more information, see |
| 270 | +[about_CommonParameters](/powershell/module/microsoft.powershell.core/about/about_commonparameters). |
| 271 | + |
| 272 | +## INPUTS |
| 273 | + |
| 274 | +### Microsoft.HyperV.PowerShell.VirtualMachine[] |
| 275 | + |
| 276 | +## OUTPUTS |
| 277 | + |
| 278 | +### Microsoft.HyperV.PowerShell.VMAssignedDevice |
| 279 | + |
| 280 | +## NOTES |
| 281 | + |
| 282 | +## RELATED LINKS |
| 283 | + |
| 284 | +[Get-VMAssignableDevice](get-vmassignabledevice.md) |
| 285 | + |
| 286 | +[Remove-VMAssignableDevice](remove-vmassignabledevice.md) |
0 commit comments