Adding several vSphere 6.5 API examples

This commit is contained in:
William Lam
2016-11-20 09:26:52 -08:00
parent 181add5bfd
commit 2d594cb60d
5 changed files with 233 additions and 0 deletions

41
Scripts/ESXInstalledVIBs.ps1 Executable file
View File

@@ -0,0 +1,41 @@
<#
.SYNOPSIS Retrieve the installation date of an ESXi host
.NOTES Author: William Lam
.NOTES Site: www.virtuallyghetto.com
.PARAMETER Vmhost
ESXi host to query installed ESXi VIBs
.EXAMPLE
Get-ESXInstalledVibs -Vmhost (Get-Vmhost "mini")
.EXAMPLE
Get-ESXInstalledVibs -Vmhost (Get-Vmhost "mini") -vibname vsan
#>
Function Get-ESXInstalledVibs {
param(
[Parameter(
Mandatory=$true,
ValueFromPipeline=$true,
ValueFromPipelineByPropertyName=$true)
]
[VMware.VimAutomation.ViCore.Impl.V1.Inventory.InventoryItemImpl]$Vmhost,
[Parameter(
Mandatory=$false,
ValueFromPipeline=$true,
ValueFromPipelineByPropertyName=$true)
]
[String]$vibname=""
)
$imageManager = Get-View ($Vmhost.ExtensionData.ConfigManager.ImageConfigManager)
$vibs = $imageManager.fetchSoftwarePackages()
foreach ($vib in $vibs) {
if($vibname -ne "") {
if($vib.name -eq $vibname) {
return $vib | select Name, Version, Vendor, CreationDate, Summary
}
} else {
$vib | select Name, Version, Vendor, CreationDate, Summary
}
}
}