Skip to content

Instantly share code, notes, and snippets.

@aaronjwood
Created May 17, 2020 16:54
Show Gist options
  • Save aaronjwood/7881f9c9af2237ba306b1cf03ed13159 to your computer and use it in GitHub Desktop.
Save aaronjwood/7881f9c9af2237ba306b1cf03ed13159 to your computer and use it in GitHub Desktop.
$dev = (Get-PnpDevice -PresentOnly).Where{ $_.InstanceId -like $instanceId }
$vm = Get-VM $vmName
$locationPath = (Get-PnpDeviceProperty -KeyName DEVPKEY_Device_LocationPaths -InstanceId $dev.InstanceId).Data[0]
Disable-PnpDevice -InstanceId $dev.InstanceId -Confirm:$false
Dismount-VMHostAssignableDevice -LocationPath $locationPath -Force -Verbose
Add-VMAssignableDevice -VM $vm -LocationPath $locationPath -Verbose
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment