Automatic IP Assignment and VLAN change in VMware View
An article by Andre Leibovici from myvirtualcloud.net
This article was first published by Andre Leibovici (@andreleibovici) at myvirtualcloud.net.
A while back I blogged about a scripting automation solution created by few VMware colleagues to automatic change the desktop VLAN in VMware View (here). The solution works great and I have received comments from organizations that have successfully implemented the scripts.
The previous solution created assume that the newly assigned VLAN will provide and allocate IP addresses to all virtual desktops via DHCP. A VMware colleague, Eric Monjoin (@emonloin), created a very simple and powerful PowerShell script that will change the virtual desktop IP address from DHCP to Fixed or Fixed to Fixed, using a pre-created .CSV file while also changing the VM portgroup assigned to the virtual desktop.
This script may help organizations that would rather have virtual desktops siting I a VLAN without DHCP and/or in a PVLAN where only RODC (Read-Only Domain Controller) are available. Adding additional security features to the virtual desktop infrastructure is never a bad idea.
If you are running Windows 7 32bits you may need to duplicate GetVMGuestNetworkInterface_windows7_64Guest.bat as GetVMGuestNetworkInterface_windows7Guest.bat in C:\Program Files\VMware\Infrastructure\vSphere PowerCLI\Scripts\. Anyway, Eric explains how to do that in his PowerShell script.
You will need to run the script in one of the available View Connection Servers because the script loads the “VMware.VimAutomation.Core” SnapIn. The VMware View PS SnapIn does not accept remote execution at this point in time.
The easiest way to execute the script is to schedule a Windows task to run it every X minutes; however it’s also possible to configure a post-sync task in VMware View that uses PowerShell Remoting (invoke-command) to call the script when a new virtual desktop has been provisioned.
>>
DISCLAIMER – The solution proposed below is a workaround and is offered without any support or warranties by me, VMware, or Eric Monjoin. It may not work in your environment for multiple different reasons. Only implement the solution if you feel conformable with the proposed setup and architecture, including scripting. Do not test the solution in production environment.
>>
ChangeIP_Change_PG_v2.txt (Download here)
