API based Powershell script for mass affinity control of AOS VMs.
This script should be targeted at Nutanix Prism Central, and is tested and built on 5.11, but should work for PC 5.10.x without any problems.
All Parameters explained below:
- VMFilter Enter Partial Name, Powershell Regex Accepted, uses match expression.
- VMInvertFilter Negates the match if set to true.
- HostFilter Enter Partial Name, Powershell Regex Accepted, uses match expression.
- HostInvertFilter Negates the match if set to true.
- ClusterIP Prism Element Cluster IP address, not used when config = $true
- ClusterUser Username of the cluster to work on, not used when config = $true
- ClusterPass Password for the cluster, not used when config = $true
- Execute will set the selected VMs on the selected hosts, it will remove previous affinity settings for that VM
- Scan will simply scan with the selected filters and send an email report of the current estate.
- CreateConfig has to be run with all SMTP and Cluster Parameters 8 total, this will create a config file in the script directory allowing the password to be stored in a hashed file. This is not perfect, but at least not readable.
- Clean used to whipe the existing Affinity settings.
- ScriptInstallDir Install directory where the PSM / config file is located, CSV are also dumpped here. Manual cleaning required.
- config Config file is used to retrieve the settings, this implies all SMTP and Cluster Variables.
- Silent Minimizes the output of the script.
- SMTPServer Servername of smtp server, not used when config = $true
- SMTPPort Port of the smtp server, not used when config = $true
- SMTPSubject Subject of the email report, not used when config = $true
- SMTPSender From address of the report, not used when config = $true
- SMTPReciever Reciever from the report, not used when config = $true
- Edit the ScriptInstallDir parameter as per its installation.
- run the script with the 8 config flags, SMTP and Cluster, and set mode to CreateConfig. (see first image)
- Check that the config is created.
Run the script in scan mode. (see second image, paramters can be hardcoded in the ps1 file header)
- Tweak the filters untill the expected result is recieved.
- Check your email if the report was sent.
- Run the script in execute mode if the above results are as expected.
Using Scan mode:
Using Execute mode: