So at first you have to set the "ExternalWFStubs.MachineProvisioned" property at the virtual machine blueprint.
As an additional input i created a custom property called "VirtualMachine.NewNetwork" which holds the name of the new network. I created a custom property with a dropdown list (Values: VM Network, DVPortGroup) to let the user select the network.
Next step was the creation of a powershell script (ChangeNetwork.ps1):
#Variable detection
$OldNetwork = $Properties["VirtualMachine.Network0.Name"]
$NewNetwork = $Properties["VirtualMachine.NewNetwork"]
$Hostname = $Properties["VirtualMachineName"]
#Check for the variables
$OldNetwork >> C:\test.txt
$NewNetwork >> C:\test.txt
$Hostname >> C:\test.txt
#Calls the powershell actions
Add-PSSnapin VMware.VimAutomation.Core
Connect-VIServer YourVcenterServer -User YourUser -Password YourPass
Get-VM -Name $Hostname | Get-NetworkAdapter | Where {$_.NetworkName -eq $OldNetwork }|Set-NetworkAdapter -NetworkName $NewNetwork -Confirm:$false
I uploaded the powershell script using the CloudUtil command line:
CloudUtil File-Import -n ChangeNetwork -f ChangeNetwork.ps1
Now i created a new workflow in the Design Center for the MachineProvisioned stub like Zack described here: Calling Powershell/PowerCLI Scripts from a vCAC workflow.
Please note that you need to initialize the Dictionary array like described in the blog post. After sending the workflow to the vCAC server the stub should call the Powershell script and change the network adapter from "DVPortGroup" to "VM Network".
After the deployment (my template has DVPortGroup as network when deployed)
the network should change with a reconfigure task.
Have fun with this!