PoshCode Archive  Artifact [40454b2154]

Artifact 40454b21546bef1cb5869465cc3472a32b5062ecfd70d773b1652af24462c1ed:

  • File VMware-Windows-Admin.ps1 — part of check-in [2a539c90cb] at 2018-06-10 13:25:41 on branch trunk — Use to get ESXi host versions (user: Clint Jones size: 1319)

# encoding: ascii
# api: powershell
# title: VMware / Windows Admin
# description: Use to get ESXi host versions
# version: 0.1
# type: module
# author: Clint Jones
# license: CC0
# x-poshcode-id: 3441
# x-archived: 2016-03-05T23:54:45
# x-published: 2013-05-30T14:19: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