Link to home
Start Free TrialLog in
Avatar of mike shaoul
mike shaoul

asked on

Powershell command doesn't work

Powershell help needed.
Wish to harden all my vm's on Esxi host. However there is one setting I need help with.
To remove all PCI devices on the vm's.
The vm advance setting would be some thing like ' passthru*present = false, but it doesn't like the wildcard.
There is a get-passthrough command, I tried :

Connect-VIServer -Server x.x.x.x -Protocol https -User root -Password xxxxxxxxx
$vms = Get-VM | where {$_.PowerState -eq "PoweredOff"}
foreach ($vm in $vms)
{Get-passthroughdevice -vm $vm | Remove-PassthroughDevice}

Open in new window



But it returned error:
Get-passthroughdevice : 04/03/2019 11:23:28	Get-PassthroughDevice		Unable to cast object of type 'VMware.Vim.VirtualPCIPassthroughVmiopBackingInfo' to type 
'VMware.Vim.VirtualPCIPassthroughDeviceBackingInfo'.	
At line:5 char:2
+ {Get-passthroughdevice -vm $vm | Remove-PassthroughDevice}
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-PassthroughDevice], VimException
    + FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.VirtualDevice.GetPassthroughDevice

Open in new window

Avatar of Qlemo
Qlemo
Flag of Germany image

Try if restricting to PCI devices helps:
Connect-VIServer -Server x.x.x.x -Protocol https -User root -Password xxxxxxxxx
Get-VM |
  where {$_.PowerState -eq "PoweredOff"} |
  Get-passthroughdevice -Type PCI |
  Remove-PassthroughDevice

Open in new window

If your host has a GPU then maybe you hitting this issue ?

https://communities.vmware.com/thread/595706
Avatar of mike shaoul
mike shaoul

ASKER

I'm using latest powercli and do not have GPU attached
ah it appears I have vGPU device installed, with the latest powershell version. What is my fix ?
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.