-
1. Re: How to Disable / Enable a VM's Network Adapter DirectPath I/O Parameter
LucD Apr 18, 2017 10:43 AM (in response to GregorSm)Try like this
$vmName = 'VM1'
$nicName = 'Network Adapter 1'
$directPath = $false # or $true to enable Direct Path IO
$vm = Get-VM -Name VM1
$nic = Get-NetworkAdapter -VM $vm -Name $nicName
$spec = New-Object VMware.Vim.VirtualMachineConfigSpec
$dev = New-Object VMware.Vim.VirtualDeviceConfigSpec
$dev.Operation = [VMware.Vim.VirtualDeviceConfigSpecOperation]::edit
$dev.Device = [VMware.Vim.VirtualDevice]$nic.ExtensionData
$dev.Device.UptCompatibilityEnabled = $directPath
$spec.DeviceChange += $dev
$vm.ExtensionData.ReconfigVM($spec)
-
2. Re: How to Disable / Enable a VM's Network Adapter DirectPath I/O Parameter
simsync Apr 20, 2017 7:04 AM (in response to LucD)Is there a way to achieve this in v6 as it looks like "'UptCompatibilityEnabled'" does not exist :(
Thanks
-
3. Re: How to Disable / Enable a VM's Network Adapter DirectPath I/O Parameter
simsync Apr 20, 2017 7:46 AM (in response to simsync)Ignore my question! I finally found the answer. It's an advanced option, so I could get its status with:
Get-VM MyVM | Get-AdvancedSetting | Where-Object {$_.Name -like "ethernet*.uptCompatibility"}And could set it like this:
Get-VM MyVM| Get-AdvancedSetting | Where-Object {$_.Name -like "ethernet*.uptCompatibility"} | Set-AdvancedSetting -Value "False" -Confirm:$false
Note that I'm using "ethernet*.uptCompatibility" to catch all NICs
-
4. Re: How to Disable / Enable a VM's Network Adapter DirectPath I/O Parameter
simsync Apr 21, 2017 12:04 AM (in response to simsync)Arggg! Also what I posted above seems not to be entirely true. In fact, I see that option enabled on multiple VMs but DirectPath I/O is disabled. I'm lost now! -
5. Re: How to Disable / Enable a VM's Network Adapter DirectPath I/O Parameter
LucD Apr 21, 2017 12:17 AM (in response to simsync)I'm not sure what you are seeing.
On the UptCompatibilityEnabled property, that was introduced in vSphere API 6.0, so the script above should work for vSphere 6.x
-
6. Re: How to Disable / Enable a VM's Network Adapter DirectPath I/O Parameter
simsync Apr 21, 2017 12:40 AM (in response to LucD)My fault! I just realised I was running an ancient version of powercli. Now I can see also ExtensionData.UptCompatibilityEnabled. -
7. Re: How to Disable / Enable a VM's Network Adapter DirectPath I/O Parameter
YashvM Oct 6, 2017 1:06 AM (in response to simsync)Hi Simsync,
I ran into the same problem running in pcli 5.5, could you please share which version of PCLi you updated to to get this working?
thanks in advance!!
-
8. Re: How to Disable / Enable a VM's Network Adapter DirectPath I/O Parameter
nickurquhart Jul 5, 2018 12:47 PM (in response to LucD)Great script, thank you!
Do you have a version of it to disable DPIO on multiple VM's? I need to apply this fix to over 300 VM's due to this bug being present when a template was created.
-
9. Re: How to Disable / Enable a VM's Network Adapter DirectPath I/O Parameter
LucD Jul 5, 2018 1:24 PM (in response to nickurquhart)You can run the code in a ForEach loop.
In the code below I just do a Get-VM, but you can make the selection more specific by using a mask or even an external file to provide the names of the VMs.
$nicName = 'Network Adapter 1'$directPath = $false # or $true to enable Direct Path IO
foreach($vm in Get-VM){
$nic = Get-NetworkAdapter -VM $vm -Name $nicName
$spec = New-Object VMware.Vim.VirtualMachineConfigSpec
$dev = New-Object VMware.Vim.VirtualDeviceConfigSpec
$dev.Operation = [VMware.Vim.VirtualDeviceConfigSpecOperation]::edit
$dev.Device = [VMware.Vim.VirtualDevice]$nic.ExtensionData
$dev.Device.UptCompatibilityEnabled = $directPath
$spec.DeviceChange += $dev
$vm.ExtensionData.ReconfigVM($spec)
}
-
10. Re: How to Disable / Enable a VM's Network Adapter DirectPath I/O Parameter
nickurquhart Jul 5, 2018 1:59 PM (in response to LucD)Thank you LucD, added in a VM mask and tested and it works perfectly!
I was struggling to put the code into the ForEach loop properly and turns out I was just massively over complicating it.
Thanks for your help! Much appreciated! :)
-
11. Re: How to Disable / Enable a VM's Network Adapter DirectPath I/O Parameter
Brewy Aug 23, 2018 5:25 PM (in response to GregorSm)Anyone else having similar issue when trying to run this against a list of VMs in a text file? Using the script below...
$nicName = 'Network Adapter 1'
$directPath = $false # or $true to enable Direct Path IO
$vmlist = Get-Content C:\Temp\VmList.txt
foreach($vm in $vmlist){
$nic = Get-NetworkAdapter -VM $vm -Name $nicName
$spec = New-Object VMware.Vim.VirtualMachineConfigSpec
$dev = New-Object VMware.Vim.VirtualDeviceConfigSpec
$dev.Operation = [VMware.Vim.VirtualDeviceConfigSpecOperation]::edit
$dev.Device = [VMware.Vim.VirtualDevice]$nic.ExtensionData
$dev.Device.UptCompatibilityEnabled = $directPath
$spec.DeviceChange += $dev
$vm.ExtensionData.ReconfigVM($spec)
}
I receive the following error...
You cannot call a method on a null-valued expression.
At E:\Scripts\DirectPathIO.ps1:13 char:4
+ $vm.ExtensionData.ReconfigVM($spec)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
I can't see any undeclared variables but doing this one by one is out of the question with over 350 VMs affected. Any help would be appreciated. Thanks.
-
12. Re: How to Disable / Enable a VM's Network Adapter DirectPath I/O Parameter
LucD Aug 23, 2018 9:10 PM (in response to Brewy)Could it be that you have a blank line in the file? At the end perhaps?
-
13. Re: How to Disable / Enable a VM's Network Adapter DirectPath I/O Parameter
Brewy Aug 23, 2018 10:15 PM (in response to LucD)Confirmed that there's no blank lines in the text file.
I've been testing with only one or two server names in VmList.txt, no spaces or blank lines in the file.
-
14. Re: How to Disable / Enable a VM's Network Adapter DirectPath I/O Parameter
LucD Aug 23, 2018 11:11 PM (in response to Brewy)Ok, I see the issue.
You are calling the ReconfigVM method on a [string] object.
Change line 3 to$vmlist = Get-VM -Name (Get-Content C:\Temp\VmList.txt)