Skip to content

Commit

Permalink
Merge pull request #3843 from Xelu86/update_vmassdev
Browse files Browse the repository at this point in the history
Update VMAssignableDevice command set - WS25
  • Loading branch information
Xelu86 committed Jul 9, 2024
2 parents d5c42c3 + ac6e6f9 commit f94da72
Show file tree
Hide file tree
Showing 4 changed files with 751 additions and 4 deletions.
275 changes: 275 additions & 0 deletions docset/winserver2025-ps/hyper-v/Add-VMAssignableDevice.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,275 @@
---
description: Assigns a device to a virtual machine.
external help file: Microsoft.HyperV.PowerShell.Cmdlets.dll-Help.xml
Module Name: Hyper-V
ms.date: 06/12/2024
online version: https://learn.microsoft.com/powershell/module/hyper-v/add-vmassignabledevice?view=windowsserver2025-ps&wt.mc_id=ps-gethelp
schema: 2.0.0
title: Add-VMAssignableDevice
---

# Add-VMAssignableDevice

## SYNOPSIS
Adds an assignable device to a specific virtual machine.

## SYNTAX

### VMName (Default)

```
Add-VMAssignableDevice [-CimSession <CimSession[]>] [-ComputerName <String[]>]
[-Credential <PSCredential[]>] [-VMName] <String[]> [-InstancePath <String>]
[-LocationPath <String>] [-VirtualFunction <UInt16>] [-ResourcePoolName <String>] [-Passthru]
[-WhatIf] [-Confirm] [<CommonParameters>]
```

### VMObject

```
Add-VMAssignableDevice [-VM] <VirtualMachine[]> [-InstancePath <String>] [-LocationPath <String>]
[-VirtualFunction <UInt16>] [-ResourcePoolName <String>] [-Passthru] [-WhatIf] [-Confirm]
[<CommonParameters>]
```

## DESCRIPTION

The `Add-VMAssignableDevice` cmdlet assigns a physical device to a specified virtual machine (VM).
This is commonly used for tasks such as attaching GPUs or network adapters directly to a VM to
enhance performance for specific applications or workloads. The device can be specified through its
instance path, location path, or assignable device object.

## EXAMPLES

### Example 1

```powershell
Add-VMAssignableDevice -VMName "MyVM" -InstancePath "PCIROOT(0)#PCI(0300)#PCI(0000)"
```

This example attaches a physical device, identified by its instance path, to the virtual machine
named **MyVM**.

## PARAMETERS

### -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](/powershell/module/cimcmdlets/new-cimsession)
or [Get-CimSession](/powershell/module/cimcmdlets/get-cimsession) cmdlet. The default is the
current session on the local computer.

```yaml
Type: CimSession[]
Parameter Sets: VMName
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -ComputerName
Specifies one or more Hyper-V hosts on which the assignable devices are to be retrieved. NetBIOS
names, IP addresses, and fully qualified domain names are allowed. The default is the local
computer. Use localhost or a dot (`.`) to specify the local computer explicitly.

```yaml
Type: String[]
Parameter Sets: VMName
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -Credential

Specifies one or more user accounts that have permission to perform this action. The default is the
current user.

```yaml
Type: PSCredential[]
Parameter Sets: VMName
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -InstancePath

Represents the Device Instance path in the host machine.

```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -LocationPath

Specifies the location path to the assignable device

```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -Passthru

Returns an object for each process that the cmdlet started.

```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -ResourcePoolName

Specifies the name of the resource pool to which the device is to be assigned.

```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -VirtualFunction

Specifies the number of the virtual function (VF) of an SR-IOV-capable network adapter assigned to
the virtual machine.

```yaml
Type: UInt16
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -VM

Specifies the virtual machine to which the device is to be assigned.

```yaml
Type: VirtualMachine[]
Parameter Sets: VMObject
Aliases:
Required: True
Position: 0
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
```

### -VMName

Specifies the name of the virtual machine to which the device is to be assigned.

```yaml
Type: String[]
Parameter Sets: VMName
Aliases:
Required: True
Position: 0
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -Confirm

Prompts you for confirmation before running the cmdlet.

```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
-InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose,
-WarningAction, and -WarningVariable. For more information, see
[about_CommonParameters](/powershell/module/microsoft.powershell.core/about/about_commonparameters).

## INPUTS

### Microsoft.HyperV.PowerShell.VirtualMachine[]

## OUTPUTS

### Microsoft.HyperV.PowerShell.VMAssignedDevice

## NOTES

## RELATED LINKS

[Get-VMAssignableDevice](get-vmassignabledevice.md)

[Remove-VMAssignableDevice](remove-vmassignabledevice.md)
Loading

0 comments on commit f94da72

Please sign in to comment.