PoshCode Archive  Artifact [3dc22a4d64]

Artifact 3dc22a4d64b7a06a7e79e8c3d7e86f709ba6c5f8a5adfdab7b3d5ee6a98cdd94:

  • File Get-VMHostVersions.ps1 — part of check-in [dada7f0495] at 2018-06-10 13:25:44 on branch trunk — Use to get ESXi host versions (user: Clint Jones size: 1315)

# encoding: ascii
# api: powershell
# title: Get-VMHostVersions
# description: Use to get ESXi host versions
# version: 0.1
# type: module
# author: Clint Jones
# license: CC0
# x-poshcode-id: 3443
# x-archived: 2016-03-22T03:48:44
# x-published: 2013-05-30T14:26:00
#
#
#========================================================================
# Created on:   5/17/2012 2:03 PM
# Created by:   Clint Jones
# Organization: Virtually Genius!
# Filename:     Get-VMHostVersions
#========================================================================

#Import modules
Add-PSSnapin "Vmware.VimAutomation.Core"

#Path to the log files
$log = "C:\Scripts\VMware\Logs\hostversions.txt"

#Creates directory structure for log files
$pathverif = Test-Path -Path c:\scripts\vmware\logs
switch ($pathverif)
    {
        True    {}
        False   {New-Item "c:\scripts\vmware\logs" -ItemType directory}
        default {Write-Host "An error has occured when checking the file structure"}
    }

#Connect to VMware servers
$viserver = Read-Host "Enter VMware server:"
$creds = Get-Credential
Connect-ViServer -Server $viserver -Credential $creds

#Get the version number of the host
Get-VMHost | Select-Object Name, Version | Format-Table -AutoSize | Out-File -FilePath $log -Append