This script performs a Controlled Recompose of a VMware View Linked Clone Pool of Virtual Desktops. It first identifies a free desktop and recomposes it to create the first Replica Desktop.
Note: If this first recompostion fails the script aborts assuming the creation of the Replica VM also failed.
After the recomposition of the first desktop, the script recomposes a specified number of additional free desktops to create a supply of recomposed systems. These desktops will be available for re-connecting users when the script next recomposes the remaining desktops in the pool, directing View to force logoff active users after the warning period specified in View Manager. An optional extra recompose can be run against the pool as the final step to provide a second attempt to recompose any desktops that may have failed.
During operation the script will abort after a specified number of timed out recompositions in a row (default 3). It will also immediately abort if it detects a View Composer error. The script can be configured to send Email Alerts to notify Administrators of both failed and successful script operations.
The script runs by default in interactive mode, prompting for required settings. It can also be run in unattended mode to support scheduled, automated maintenance.
All features supported by the scripts are controlled by script parameters. See Instructions for information about the parameters.
Remove .txt extension (if any) of the script and copy it under any script directory on the connection server. Run the command with the “help” parameter to obtain detail command line option. It is recommended that the user run powershell command as “Administrator”.
These parameters do not have default settings and are required to enable Unattended Mode. If not specified on the command line the script will prompt for these (unless unattend mode is configured in which case the script will abort).
- Pool – Specifies the Pool to recompose
- ParentVM – The full path to the Parent VM to use for the recomposition
- NewSnapshot – The new snapshot to use for the Recomposition including full path.
These parameters impact the operation of the recomposition and have defaults which can be overridden on the command line. The defaults are located near the beginning of the script under a corresponding comment heading.
- RecomposeAtATime – The number of desktops to recompose at a time.
- Current default setting: 2
- Desktops2Prep – The number of free desktops to prepare before recomposing active desktops. Ensures a supply of recomposed (ready) desktops are available for reconnecting users.
Current default setting: 4
- RecomposeTimeout – The amount of time in seconds before a recompose operations times out.
- Current default setting: 1500
- Timeouts2Abort – The number of timed out batches in a row before the script aborts.
Current default setting: 3
- UnattendDelay – The amount of time the recomposition configuration summary is displayed in unattend mode before starting the process.
Current default setting: 60
- -ConnectionServer – The IP address OR fully qualified domain name of the View Connection Server.
Current default setting: 127.0.0.1
Special Setting: Unattend
Specify: unattend on the command line to configure the script to run in unattended mode. In this mode the script does not prompt for input enabling it to be scheduled. If unattended mode is set, the recompose parameters -Pool, -ParentVM and -NewSnapshot must also be specified on the command line or the script will abort. Note: this setting does NOT have a preceding hyphen (-).
Special Setting: ExtraRecomp
Use the ExtraRecomp setting to direct the script to run an extra recomposition against the entire pool as the final step. This will give the system a second attempt to recompose any desktops that may have timed out. Note: that this setting does NOT have a preceding hyphen (-).
The script can be configured to send email alerts by either specifying the following parameters on the command line or by modifying the default email settings at the beginning of the script. -EmailFrom, -EmailTo, and -SMTPServer are required. If all three are configured the script will enable itself to send email alerts.
The remaining settings are optional. By default -SMTPport is set to 25 and -UseSSL is disabled.
Required Email Settings
- EmailTo – multiple addresses can be separated by commas
Optional Email Settings
- SMTPport – 25 is default. 587 is typically used for SSL
- UseSSL – specify Y or 1 to enable. Default is disabled.
The colors used by the script can be modified.
The following colors are supported by Powershell: Black, DarkBlue, DarkGreen, DarkCyan, DarkRed, DarkMagenta,DarkYellow, Gray, DarkGray, Blue, Green, Cyan, Red, Magenta, Yellow, White.
RecomposeScript.ps1 -pool HRPool-01 -newsnapshot /firstsnap/decemberupdates -parentvm /datacenter/vm/VirtualDesktops/Win7Desk1 -RecomposeTimeout 1500 unattend
RecomposeScript.ps1 -RecomposeAtATime 8 -Desktops2Prep 40 -pool HRPool-01 -newsnapshot /firstsnap/decemberupdates -parentvm /datacenter/vm/VirtualDesktops/Win7Desk1 extrarecomp
RecomposeScript.ps1 -emailfrom firstname.lastname@example.org -emailto email@example.com,firstname.lastname@example.org -usessl 1 -smtpport 587
you can download the script from here
This fling is covered under the MIT License.