Snapshots, if left undetected will grow and consume space as well as slow your VMs down if you have enough of them. This is an endless battle for the system administrator as (in my experience) developers will want to keep snapshots forever. This often leads to the same “snapshots are not backups” conversation. In this…
Category: PowerShell
Powershell tutorial, Jobs part 1
Powershell code runs synchronously. This means that one line is processed at a time until the end of the script is reached. This is fine for most scripts but there will be situations where this type of execution is not ideal. A port scanner for example would take forever if it ran synchronously. When creating…
Powershell tutorial, Jobs part 2
Here is a Ping sweeper script using Powershell jobs to speed things up. The script works (at a high level) like this: I create an array of IP addresses to scan. I loop through each IP If I am running the max number of concurrent jobs, wait for some jobs to finish, add the results…
Find VMs restarted by HA
Administer VMWare long enough and you will eventually lose a host. If you are using HA you may not notice until the phones start ringing some time later. At this point all the VMs are back on line on different hosts. When Problem management/bosses get involved you will normally be asked “what VMs restarted?”here is…
Powershell Dot-Source
Using Dot Sourcing is a quick and easy way of getting functions or data into your Powershell console or script. If you run a Powershell script from a console, all the data in memory is deleted when the script ends (unlike the ISE where it is still in memory).This is because the script is running…
Find and remove connected CD drives using PowerCLi
If you work in an environment where no one remembers to disconnect their ISO images when done then this script is for you. This script will report each VM with a connected CD drive and its ISO path, to a CSV fileAlso once a specified number of days have passed (assuming this script is run…
My Powershell Ping function
This is a nicer looking (than) Ping function I wrote in Powershell a while ago. It’s a simple Ping function that only writes a new line when there is a state change. So the output is much neater then a ping -t command that rapidly scrolls off the screen. The function will take the following…
Getting and Setting the Scratch location
The scratch partition on an ESXi host stores log information and will be set to the RAM drive by default. This means that any information written there will not survive a reboot, or could interfere with the stability of the host in low memory situations. Getting and setting the scratch location is quite easy with…
VM disk audit script
This script scans all VMs in a vCenter and reports the location of each hard drive. The information collected for each drive is as follows: VM, Thick/Thin, file path, datastore, capacity, size on disk, Number of snapshots, total size of snapshots.