Home > Blogs > VMware PowerCLI Blog


Top 3 Scripts and Tools for July 2014

July_Scripts

Another month has come and gone and it’s due time that I post this months script spotlights. There are three scripts that I am excited to highlight this month. So let’s get down to business.

1. vCheck

I had several people reach out to me telling me that vCheck should be placed in the spotlight. This was already on my list for “Top 3 Scripts” posts. However, all of the messages I received from members of the community has since pushed this to be the #1 script for July.

What is vCheck?

vCheck, created by Alan Renouf (@alanrenouf), is a script that gives great depth and vision into your environment. vCheck can be run as a scheduled task that can email you a very neatly-formatted report.
vcheck_report

What does it check?

The following is a list of items that are reported on via vCheck:

  • General Details
    • Number of Hosts
    • Number of VMs
    • Number of Templates
    • Number of Clusters
    • Number of Datastores
    • Number of Active VMs
    • Number of Inactive VMs
    • Number of DRS Migrations for the last days
  • Snapshots over x Days old
  • Datastores with less than x% free space
  • VMs created over the last x days
  • VMs removed over the last x days
  • VMs with No Tools
  • VMs with CD-Roms connected
  • VMs with Floppy Drives Connected
  • VMs with CPU ready over x%
  • VMs with over x amount of vCPUs
  • List of DRS Migrations
  • Hosts in Maintenance Mode
  • Hosts in disconnected state
  • NTP Server check for a given NTP Name
  • NTP Service check
  • vmkernel warning messages ov the last x days
  • VC Error Events over the last x days
  • VC Windows Event Log Errors for the last x days with VMware in the details
  • VC VMware Service details
  • VMs stored on datastores attached to only one host
  • VM active alerts
  • Cluster Active Alerts
  • If HA Cluster is set to use host datastore for swapfile, check the host has a swapfile location set
  • Host active Alerts
  • Dead SCSI Luns
  • VMs with over x amount of vCPUs
  • vSphere check: Slot Sizes
  • vSphere check: Outdated VM Hardware (Less than V7)
  • VMs in Inconsistent folders (the name of the folder is not the same as the name)
  • VMs with high CPU usage
  • Guest disk size check
  • Host over committing memory check
  • VM Swap and Ballooning
  • ESXi hosts without Lockdown enabled
  • ESXi hosts with unsupported mode enabled
  • General Capacity information based on CPU/MEM usage of the VMs
  • vSwitch free ports
  • Disk over commit check
  • Host configuration issues
  • VCB Garbage (left snapshots)
  • HA VM restarts and resets
  • Inaccessible VMs

I have to say, if I could have a “Script of the Year” it would be vCheck. Recently at the Salt Lake City VMware User Conference I asked the group I was presenting to if they had used vCheck. only a handful knew what it was, but those who did raved about it. Many hats off to Alan for the time he took to create this handy script.

You can find out more about vCheck HERE. – Alan Renouf www.virtu-al.net

2. Migrate cluster from one vCenter to another vCenter

Have you ever wanted or needed to move a cluster from one vCenter to another? Mark Chuman has written a nice script and included functions to do just that! Some of the settings this script deals with include:

  • HA settings
  • DRS Settings
  • EVC
  • DRS vm rules (affinity/anti-affinity)
  • folder import/export
  • Permissions

(Note*: this does not deal with Distributed virtual Switches as they use standard vSwitches)

The script is as easy as unzipping the directory and running with PowerCLI

vC Cluster 2 vc Cluster

You can download the script and give a shoutout to Mark for his script HERE. – Mark Chuman

3. Get VM ToolsVersion –

This last month I was in the middle of writing up a blog post on this great new feature of PowerCLI 5.5 r2, where ‘ToolsVersion’ property was added to VMGuest, which returns the version as a string (If you have tried to script this before, you’ll remember that previously this had to be done using views), when I saw that Eric Shanks beat me to the punch by about 10 minutes! (Good for you Eric!)

Although this script is not as long or as robust as the previous two scripts highlighted this month, this has come as a much welcomed update to PowerCLI. In Eric’s post, he shows both the old way and the new way of returning the VMTools Version.

Screenshot 2014-08-05 19.37.41

You can read Eric’s post HERE to see how he returns the ToolsVersion value of VMs in his environment. – Eric Shanks – www.theithollow.com

SUMMARY

Another great month of activity around PowerCLI in the community. If you have a favorite script that you think should be featured in an upcoming “Top 3 Scripts” post, you can comment below or message @vTagion on Twitter.

(Note*: As always, you should NEVER run these scripts unless you have looked through the code and completely understand what they do.)

 

This entry was posted in General, Reporting and tagged , , , on by .
Brian Graf

About Brian Graf

Brian Graf is a Senior Product Manager - Distributed Resource Management (DRS/HA/DPM) at VMware. Previous to Product Management, Brian worked as a Senior Technical Marketing Manager at VMware, focused on PowerCLI Automation and ESXi Lifecycle technologies. Previous roles also include: Consultant for EMC Consulting. His main focus was Data center migration methodologies and implementations. His background previous to VMware includes Operations Engineering, Virtualization, Business Intelligence, and Exchange/Blackberry Engineering. Get notification of new blog postings and more by following Brian on Twitter: @vBrianGraf

5 thoughts on “Top 3 Scripts and Tools for July 2014

  1. Pingback: All quiet before the VMworld storm – vNews August 2014 | Stu McHugh's Virtualisation Blog

  2. Jason

    It is possible to pull the ToolsVersion property using Get-View and pulling the long version (ie 9.4.5) instead of pulling the current 4 digit version available via Get-View? If its not possible to pull this property via Get-View, can we convert the 4 digit version to the version number displayed by Get-VMGuest?

    Reply
  3. Pingback: Newsletter: August 16, 2014 | Notes from MWhite

  4. narendar

    could u pls provide creation and deletion of template script with email alert
    template should delete after 24 hours

    Reply
  5. JT

    Will someone please review the script below and confirm that this will stop and start the server and whether it will do this with the userid of the account running it in the audit log for both the stop and start command. As when run it appeared to use a system account for the start command in the audit log? Many thanks in advance…
    ###################################################
    # #
    # Shutdown and Restart Redundant Exchange Servers #
    # Created: 11/11/2016 #
    # #
    ###################################################

    $UserCredential=IMPORT-CLIXML “C:\Scripts\Credentials\CoreSecureCredentials.xml”

    Connect-VIServer VS162 -Credential $UserCredential

    Function Get-ViSession {
    Get-VISession

    .EXAMPLE
    PS C:\> Get-VISession | Where { $_.IdleMinutes -gt 5 }
    #>
    $SessionMgr = Get-View $DefaultViserver.ExtensionData.Client.ServiceContent.SessionManager
    $AllSessions = @()
    $SessionMgr.SessionList | Foreach {
    $Session = New-Object -TypeName PSObject -Property @{
    Key = $_.Key
    UserName = $_.UserName
    FullName = $_.FullName
    LoginTime = ($_.LoginTime).ToLocalTime()
    LastActiveTime = ($_.LastActiveTime).ToLocalTime()

    }
    If ($_.Key -eq $SessionMgr.CurrentSession.Key) {
    $Session | Add-Member -MemberType NoteProperty -Name Status -Value “Current Session”
    } Else {
    $Session | Add-Member -MemberType NoteProperty -Name Status -Value “Idle”
    }
    $Session | Add-Member -MemberType NoteProperty -Name IdleMinutes -Value ([Math]::Round(((Get-Date) – ($_.LastActiveTime).ToLocalTime()).TotalMinutes))
    $AllSessions += $Session
    }
    $AllSessions
    }

    $Connections = get-vm | get-snapshot | format-list

    $Sessions = Get-ViSession

    $vmserver rs=Get-VM VS153-EXCH-CAS-1

    if (get-VIAccount !()) {

    #$vmserver| Shutdown-VMGuest -Confirm:$false

    Sleep 500

    Start-VM -VM $vmserver

    }

    $vmserver rs=Get-VM VS154-EXCH-CAS-2

    if (get-VIAccount !()) {

    #$vmserver| Shutdown-VMGuest -Confirm:$false

    Sleep 500

    Start-VM -VM $vmserver

    }

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

*