This repository contains vSphere, NSX, and Site Recovery Manager (SRM) scripts. It is a collection of examples with different levels of implementation and verification. Review each script and test it against a nonproduction system before using it in operations.
The historical examples in vsphere, nsx, and srm target the vSphere 8.x, NSX 4.2.x, and VMware.PowerCLI 13.x generation. The original commits were posted July 23, 2025. See historical version scope for the release-date evidence, the separate Live Site Recovery version line, and compatibility limits. Their behavior on VCF 9.x has not been validated.
New read-only examples for the VCF 9.1.x generation are in the separate VCF 9.1.x reports collection. Their API paths and PowerCLI commands are documented there; live behavior remains unverified.
| Example | What it does | Safety and verification |
|---|---|---|
| Snapshot cleanup | Finds vSphere snapshots older than a chosen age | Preview by default; a named VM or explicit all-VM scope is required to apply. Selection logic has unit tests. |
| VM rename | Plans VM inventory renames from a CSV | Preview by default; rejects duplicate and conflicting names. Validation logic has unit tests. |
| NSX firewall CSV importer | Plans NSX distributed firewall policies and rules | Local preview by default; validates CSV fields and object references before API writes. Plan logic has unit tests. |
These tests do not establish live compatibility. See the script status guide and workflow notes before selecting an example.
- Install Python 3.11 or later and run
python -m pip install -r requirements.txtfor Python scripts. - Install VMware.PowerCLI 13.3 for the historical PowerShell scripts and check the module version before running them. The new VCF 9.1.x reports have separate setup instructions.
- Copy the relevant
vsphere/.env.example,nsx/.env.example, orsrm/.env.exampleto.envin that directory. Supply credentials through your normal secret management process. Never commit.envfiles. - Trust the issuing CA for vCenter, NSX, or SRM. For Python scripts that support a custom CA, set the corresponding
VCENTER_CA_BUNDLEorNSXT_CA_BUNDLEenvironment variable.
The vSphere snapshot removal and NSX firewall CSV importer preview their planned changes by default and require --apply to write. Other scripts may change infrastructure immediately. Read their code and documentation before running them.
- The SRM Python workflows stop before generating output because their API integration is incomplete.
- Many SRM and NSX PowerShell examples refer to commands outside the published PowerCLI modules. They now check for those commands before requesting credentials and stop if the commands are unavailable. The SRM module exposes its API through
Connect-SrmServerand the connection'sExtensionDataproperty. Check the installed VMware.PowerCLI 13.x help for that command; current online command pages may describe later module versions. - Several vSphere inventory reports now read actual vCenter objects through pyVmomi. Reports that need unavailable backup, CMDB, NSX, SRM, or historical data stop before creating an operational report. Remaining placeholder fields must not be treated as measured results.
- The repository has static syntax checks and a small unit test suite. Live API behavior needs validation on the product versions in use.
Copyright (c) 2025-2026 Paul Bryant. All rights reserved. No permission to copy, modify, or redistribute the code is granted by this repository. See copyright and reuse.
See onboarding, contributing, and security reporting.