Skip to content

Get-HostPatch_Html

VMware: Creates a report with the host patches installed on the specified host

#Requires -Version 5.1
#Requires -Modules VMware.VimAutomation.Core
[CmdletBinding()]
Param(
    [Parameter(Mandatory = $true)]
    [string]$VIServer,
    [Parameter(Mandatory = $true)]
    [pscredential]$VICredential,
    [Parameter(Mandatory = $true)]
    [string]$HostName
)
Process {
    $vmServer = $null
    try {
        [string[]]$Properties = @('Name', 'InstallDate', 'AcceptanceLevel', 'CreationDate', 'ID', 'Status', 'Vendor', 'Version')
        $vmServer = Connect-VIServer -Server $VIServer -Credential $VICredential -ErrorAction Stop
        $timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
        $vmHost = Get-VMHost -Server $vmServer -Name $HostName -ErrorAction Stop
        $result = (Get-ESXCli -VMHost $vmHost).software.vib.list() | Select-Object $Properties
        foreach ($item in $result) {
            $item | Add-Member -NotePropertyName 'Timestamp' -NotePropertyValue $timestamp -Force
        }
        $html = $result | ConvertTo-Html -Fragment
        Write-Output $html
    }
    catch { throw }
    finally { if ($null -ne $vmServer) { Disconnect-VIServer -Server $vmServer -Force -Confirm:$false -ErrorAction SilentlyContinue } }
}

IP address or DNS name of the vSphere server

PSCredential object for authenticating with the server

Name of the host to retrieve patches from

An interactive directory of PowerShell scripts.