Hi!
There are examples on the internet on how to get this setting, like
(Get-VM -Name "a-vm-name" | Get-NetworkAdapter).ExtensionData.UptCompatibilityEnabled
but there is none on how to set it. I know I could use Onyx but my vCenter has overtaken it (6.0 --> 6.5). Maybe I can get a quicker answer here...
Thanks
Gregor
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)
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
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)
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Is there a way to achieve this in v6 as it looks like "'UptCompatibilityEnabled'" does not exist 😞
Thanks
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
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
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
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!!
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.
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.
$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)
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
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! 🙂
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.
Could it be that you have a blank line in the file? At the end perhaps?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
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.
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)
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
That was it... thanks for your help!
Hello LucD,
The code provided doesn't throw any error. However when I double check the vmx file the result is not applied and the previous value persist.
I have copy/paste your code, and to verify the value of "$dev.Device.UptCompatibilityEnabled" I collect it before and after the config is applied.
I have also check in the vmx file and the value for the UptCompatibilityEnabled persist.
The line $vm.ExtensionData.ReconfigVM($spec) looks to not apply the config to the vmx file.
Is anyone else who notice that behavior ?
I am on ESXi 6.5 U2
Thanks !
Regis B
The settings in the VMX are not updated immediately.
Was the VM powered off when you ran the script?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
i know it is an old post, but I have a lot of vms , with DirectPath I/O enabled. when I have tried to run the script the $dev.Device variable returns Null.
any idea?
Since that value comes from the $nic variable, is there anything in there?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference