Here you can find the code of the scripts I published on the vmutils blog.
This place has better functionality for questions/discussions so I will try to keep them here. However, if you don't have a communities account you can post your question on the blog (doesn't require account).
I suggest you run "# Set-ExecutionPolicy bypass" in the PowerCLI shell before using the scripts to avoid having to answer questions every time you use them. For more info see this and this
Running the .\NLclonePodsofVapp.ps1 keeps asking me to confirm Security Warnings
PowerCLI C:\training\PowerCLI\Scripts\ClonevApps> .\NLclonePodsofVapp.ps1 SRM-Base-Config SRM50-Student 1
Security Warning
Run only scripts that you trust. While scripts from the Internet can be useful, this script can potentially harm your computer.
Do you want to run C:\training\PowerCLI\Scripts\ClonevApps\NLclonePodsofVapp.ps1?
[D] Do not run [R] Run once [S] Suspend [?] Help (default is "D"): R
vSwitch created
Security Warning
Run only scripts that you trust. While scripts from the Internet can be useful, this script can potentially harm your computer.
Do you want to run C:\training\PowerCLI\Scripts\ClonevApps\LcloneVapp.ps1?
[D] Do not run [R] Run once [S] Suspend [?] Help (default is "D"): R
Security Warning
Run only scripts that you trust. While scripts from the Internet can be useful, this script can potentially harm your computer.
Do you want to run C:\training\PowerCLI\Scripts\ClonevApps\LcloneVM.ps1?
[D] Do not run [R] Run once [S] Suspend [?] Help (default is "D"): R
Name PowerState Num CPUs Memory (MB)
---- ---------- -------- -----------
SRM50-Student-Pod... PoweredOff 1 2048
MacAddress : 00:50:56:01:00:cb
WakeOnLanEnabled : False
NetworkName : SRM50-Student-Pod01
Type : e1000
ParentId : VirtualMachine-vm-208
Parent : SRM50-Student-Pod01-CEL-A
Uid : /VIServer=administrator@10.21.71.141:443/VirtualMachine=VirtualMachine-vm-208/NetworkAdapter=4000/
ConnectionState : NotConnected, GuestControl, StartConnected
ExtensionData : VMware.Vim.VirtualE1000
Id : VirtualMachine-vm-208/4000
Name : Network adapter 1
Running the removeLclonePods
1. Does not list the switches to be deleted
2. Does not delete the vSwitch after the vApp is deleted
PowerCLI C:\training\PowerCLI\Scripts\ClonevApps> .\removeLclonePods.ps1 SRM50-Student-Pod
Do you want to delete from disk the following vApps and vSwitches?
Note that the vSwitch should only be removed when ALL the Pods with the corresponding name are NOT going to be used anymore.
------ vApps -------------
Name
----
SRM50-Student-Pod01
------ vSwitches ---------
Answer y/[n]?: y
I am happy that you brought that out.
The vSwitch gets deleted if it gets found according with the argument you provided.
Let's say you created 2 Pods with
> .\NLclonePodsofVapp.ps1 SRM-Base-Line SRM50-Student 2
If you try to remove using the command below you will target only that Pod, not touching the vSwitch.
> .\removeLclonePods.ps1 SRM50-Student-Pod01
Do you want to delete from disk the following vApps and vSwitches?
Note that the vSwitch should only be removed when ALL the Pods with the corresponding name are NOT going to be used anymore.
------ vApps -------------
Name
----
SRM50-Student-Pod01
------ vSwitches ---------
Answer y/[n]?: n
If you try to remove using the command below you will target the Pods that start with 0 (zero), not touching the vSwitch.
> .\removeLclonePods.ps1 SRM50-Student-Pod0
Do you want to delete from disk the following vApps and vSwitches?
Note that the vSwitch should only be removed when ALL the Pods with the corresponding name are NOT going to be used anymore.
------ vApps -------------
Name
----
SRM50-Student-Pod01
SRM50-Student-Pod02
------ vSwitches ---------
Answer y/[n]?: n
And if you want to delete ALL the Pods AND the vSwitch, then you would give the same argument you used for the creation of the Pods, that is, you destroy the same thing you created; SRM50-Student => SRM50-Student
> .\removeLclonePods.ps1 SRM50-Student
Do you want to delete from disk the following vApps and vSwitches?
Note that the vSwitch should only be removed when ALL the Pods with the corresponding name are NOT going to be used anymore.
------ vApps -------------
Name
----
SRM50-Student-Pod01
SRM50-Student-Pod02
------ vSwitches ---------
vSwitch-Isolated-SRM50-Student
Answer y/[n]?: n
This is by design, because as indicated, the vSwitch should only be removed when the Pods connected to it are not going to be used anymore. So if you want to delete it, you will have to delete the Pods too.
Because the name of a vSwitch has to be <32 characters, the size of the common name for the Pods has to be <32-17 , that is <15 characters. (Update: This requirement has been relaxed on the version 5 of the scripts).
In the case below, the destination name (VSAManagerInstalled) is not <15 characters long.
This is the error you will get if you don't respect this restriction.
PS C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI> .\NLclonePodsofVapp.ps1 Base--VSA-Installed VSAManagerInstalled 4
New-VirtualSwitch : 01/09/2011 12:40:14 New-VirtualSwitch A specified parameter was not correct.
At C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\online.version_zip\NLclonePodsofVapp.ps1:106 char:41
+ else {$vs = $vmhost | New-VirtualSwitch <<<< -Name "vSwitch-Isolated-$cloneName"}
+ CategoryInfo : NotSpecified: (:) [New-VirtualSwitch], InvalidArgument
+ FullyQualifiedErrorId : Client20_VmHostServiceImpl_NewVirtualSwitch_ViError,VMware.VimAutomation.ViCore.Cmdlets.Commands.Host.NewVirtualSwitch
vSwitch created
New-VirtualPortGroup : Cannot validate argument on parameter 'VirtualSwitch'. The argument is null or empty. Supply an argument that is not null or empty and then try the command again.
At C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\online.version_zip\NLclonePodsofVapp.ps1:119 char:63
+ foreach ($vs in $vslist){ $vpg = $vs | New-VirtualPortGroup <<<< -Name "$cloneName-Pod$i" -vlanID $i; }
+ CategoryInfo : InvalidData: (:) [New-VirtualPortGroup], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutomation.ViCore.Cmdlets.Commands.Host.NewVirtualPortGroup
The VM: Student--VSA-Pod73-bVC_with_VSA_1.0_v6 has no snapshot. Exiting.
New-VirtualPortGroup : Cannot validate argument on parameter 'VirtualSwitch'. The argument is null or empty. Supply an argument that is not null or empty and then try the command again.
At C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\online.version_zip\NLclonePodsofVapp.ps1:119 char:63
+ foreach ($vs in $vslist){ $vpg = $vs | New-VirtualPortGroup <<<< -Name "$cloneName-Pod$i" -vlanID $i; }
+ CategoryInfo : InvalidData: (:) [New-VirtualPortGroup], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutomation.ViCore.Cmdlets.Commands.Host.NewVirtualPortGroup
Today, while creating some Pods I had an error on VC (see attachment):
Add virtual switch
Operation failed, diagnostics report: Sysinfo error on operation returned status:
Limit exceeded. Please see the VMkernel log for detailed error information.
As instructed I checked the vmkernel and I found this:
2012-03-21T16:18:05.450Z cpu4:2846)WARNING: NetPortset: 708: Isolated-View.5.1_v4: too many ports on system already (4960, limit is 4608)
2012-03-21T16:18:05.450Z cpu4:2846)Uplink: 2411: Couldn't find UplinkPS Isolated-View.5.1_v4.
2012-03-21T16:18:05.450Z cpu4:2846)WARNING: Net: 1397: can't create portset: Limit exceeded
2012-03-21T16:21:17.922Z cpu8:133054)WARNING: NetPortset: 708: Isolated-View.5.1_v4: too many ports on system already (4960, limit is 4608)
2012-03-21T16:21:17.922Z cpu8:133054)Uplink: 2411: Couldn't find UplinkPS Isolated-View.5.1_v4.
2012-03-21T16:21:17.922Z cpu8:133054)WARNING: Net: 1397: can't create portset: Limit exceeded
2012-03-21T16:24:59.842Z cpu1:251796)WARNING: NetPortset: 708: Isolated-View.5.1_v4: too many ports on system already (4960, limit is 4608)
2012-03-21T16:24:59.842Z cpu1:251796)Uplink: 2411: Couldn't find UplinkPS Isolated-View.5.1_v4.
2012-03-21T16:24:59.842Z cpu1:251796)WARNING: Net: 1397: can't create portset: Limit exceeded
Apparently I hit the maximum number of ports.
I include some configuration maximums from the pdf.
It's incredible the massive overcommitment I can achieve with this little program in a very short period, while keeping freedom to modify anything anytime.