I would like to add this line, RemoteDisplay.maxConnection=1, to VM configuration parameters. Can anyone help me with doing this in vitoolkit script as I don't think doing it in 150 VMs manually is a good idea.
Thank you.
You can do it like this
$vmcsv = import-csv "c:\all-vms.csv" $key = "RemoteDisplay.maxConnections" $value = 1 foreach ($vmguest in $vmcsv) { $vm = Get-VM $vmguest.vm | Get-View $vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec $vmConfigSpec.extraconfig += New-Object VMware.Vim.optionvalue $vmConfigSpec.extraconfig[0].Key=$key $vmConfigSpec.extraconfig[0].Value=$value $vm.ReconfigVM($vmConfigSpec) }
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
See Carter's blog entry on how to add/change the VMX entries.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks. I've make some changes to load from a csv file with all vms (where I can use this in the future if I need to change couple not all)
$vmcsv = import-csv "c:\script\all-vms.csv"
$key = RemoteDisplay.maxConnections
$value = 1
foreach ($vmguest in $vmcsv)
{
$vm = Get-VM $vmguest.vm | Get-View $_.Id
$vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
$vmConfigSpec.extraconfig += New-Object VMware.Vim.optionvalue
$vmConfigSpec.extraconfig[0].Key=$key
$vmConfigSpec.extraconfig[0].Value=$value
$vm.ReconfigVM($vmConfigSpec)
}
}
The csv file contain a column with title 'vm' follow by the vm name.
Not sure if my changes will work. Is it posible if you can verify if I did it correctly?
Thank you.
You can do it like this
$vmcsv = import-csv "c:\all-vms.csv" $key = "RemoteDisplay.maxConnections" $value = 1 foreach ($vmguest in $vmcsv) { $vm = Get-VM $vmguest.vm | Get-View $vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec $vmConfigSpec.extraconfig += New-Object VMware.Vim.optionvalue $vmConfigSpec.extraconfig[0].Key=$key $vmConfigSpec.extraconfig[0].Value=$value $vm.ReconfigVM($vmConfigSpec) }
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference