VMware Cloud Community
tchiew_a
Enthusiast
Enthusiast
Jump to solution

Limit user access VI Console

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.

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

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

View solution in original post

0 Kudos
3 Replies
LucD
Leadership
Leadership
Jump to solution

See Carter's blog entry on how to add/change the VMX entries.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

tchiew_a
Enthusiast
Enthusiast
Jump to solution

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.

0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

0 Kudos