VMware PowerCLI 101
Blog post:At VMworld US 2019, Brian Bunke and Kyle Ruddy presented session HBI1743BU - "Introduction to PowerCLI." It was intended for those new to PowerShell and/or PowerCLI to see it in action -- hopefully making the command line a little more familiar -- and to provide a permanent "how to get started" example via recorded video and this code repository.
Demo Files
0 - Setup.ps1
- Get/update PowerCLI; connect to vCenter; perform optional one-time setup tasks
1 - Intro.ps1
- Discover infrastructure; use the pipeline and a variable; display other object properties
2 - VM snapshots.ps1
- Discoverability in PowerShell; find and remove old VM snapshots
3 - VM tags.ps1
- Tag lifecycle: create, read, update, delete ("CRUD" operations)
4 - VM creation date.ps1
- Explore the
ExtensionData
property to view a new vSphere 6.7 feature
- Explore the
5 - Extras.ps1
- Some code examples of ideas we introduced but didn't have time to cover during the session:
- Get VM by MAC address
- Find VMs with connected media drives
- Data manipulation and reporting
- Compare host DNS/NTP entries
- Check the "Upgrade VMware Tools before each power on" box on all VMs
- Some code examples of ideas we introduced but didn't have time to cover during the session: