One this that has always bugged me with vCenter UIs is seeing a reconfigure VM task but not being able to tell what was changed. Some times in an investigation this can be very important. While looking at Event objects one day I discovered an attribute called configchanges on a reconfigured event object. In there…
Category: PowerCLi
Get tasks with events
Here is a script to get tasks (historic tasks not just current) and also the events associated with that task.This is very handy for auditing or troubleshooting. The task collection part of the script I found on LucD blog at https://www.lucd.info/tag/get-task/ Basically this will get all tasks and events for a specific time frame. It…
PowerCli One-liners
Here is a page of One liners I have written/collected over the years. I will add more over time. # Lists eachs hosts VMKernal interfaces with there PortGroup, IP and MTU. # Set all NetApp LUNs to RoundRobin # get all hosts NTP servers. # Get current and configured scratch location. # get PortGroup, IP and…
Getting tasks from VMWare
If you use the flash client to administer a vCenter server then you will know how bad it is at updating the task list. Here is a handy powershell example of getting a list of running tasks. Only need to see running tasks? Values for -Status can be: Error, Queued, Running, and Success That is…
Powershell Tutorial Dealing with Snapshots
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…
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…
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.