VMware PowerCLI Script Library

I’m moving scripts to GitHub

Mainly because it’s cool, but the formatting of scripts in wordpress is horrible, and I need to revisit most as I found mistakes in some, what’s in GitHub has been recently tested

https://github.com/raoconnor

 

 

 

Get-ByBlueFolders Series

Many of us divide services or customers using blue folders, typically in a multi service enviroment
The following are scripts that can be run against all vms in a folder

Get-bybluefolder list vm harddisk and scsi-id information

List information for virtual machine harddisk, harddisk number, size, scsi id, and raw canonical name
This can be run against a single vm or all vms in a blue folder (use get-folder to list folder names…)

 

Get-bybluefolder list vm datastores

List virtual machine datastores for all vms in a blue folder

 

 

Export VIPermissions and Roles to xml

This is a really useful piece of code to extract vCenter roles and permissions to an xml file. The gain is that with the help of an xml reader it is a simple task to filter and drill down into the xml file and see how roles, users and permissions are assigned.

Get time of virtual machine reboot

After a unexpected host reboot, quickly being able to list the last reboot time of vms, will help your application and systems guys to focus validation checks
The gain is that the script gives the time and date rather that the uptime, a fixed point in time is what your escalation and quality team will want to see in post-mortem review.

Reconfigure NTP Servers by esx cluster

Changing ntp on a large number of host by hand is not my idea of being productive
Here is a script that brings together available code and will help change the ntp servers that your hosts use cluster by cluster.

Configure dump collector on esxi hosts

VMware’s Dump Collector is a useful tool from troubeshooting PSOD and unexpected host reboots. Once you have set up the dump collector the hosts need to be configured. Jonathan Medd created a couple of really useful PowerCLI functions that can save a whole bunch of time.

find a vm’s mac in a haystack

Quickly locate the owner of a mac address

Get and Set Advanced Log Setting on Host

Modify host advanced logging settings

Create vMotion Report

Create a report of DRS VMotions/ SDRS SVMotion events

Get-StorageLunPaths

Check on Lun path state for hundreds of hosts in a moment

Compare vm cpu peak with cpu limit

If you are using vm cpu mhz limits, (well you shouldn’t  be…*) but if you are, this might be helpful, as it allows you to see if vms are hitting the limit
yellow-bricks – limiting your vcpu

 

Get-VmReadySpikesForXDays

Check cpu ready values for single vm or per cluster, some of the coolest code I’ve worked on, elegant and relevant

 

Get-vmMhzUsage

Get virtual machine usage in mhz

 

get physcial switch port information

During fork lift host migrations or physical switch replacement, being able to extract physical port and switch information is vital
I found this at 2 am one morning, when the network guys realized that the switches/servers hadn’t been corrected connected to the the right cables.