forked from dstamen/PowerCLI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Install-HostVIB.ps1
37 lines (28 loc) · 1.17 KB
/
Install-HostVIB.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# PowerCLI Script for installing a VIB to a host
# @davidstamen
# http://davidstamen.com
# Define Variables
$Cluster = "Cluster"
$vibpath = "/vmfs/volumes/NFS01/VIB/cisco/scsi-fnic_1.6.0.24-1OEM.600.0.0.2494585.vib"
$vcenter = "vcenter.lab.local"
$cred = Get-Credential
# Connect to vCenter
Connect-VIServer -Server $vcenter -Credential $cred
# Get each host in specified cluster that meets criteria
Get-VMhost -Location $Cluster | where { $_.PowerState -eq "PoweredOn" -and $_.ConnectionState -eq "Connected" } | foreach {
Write-host "Preparing $($_.Name) for ESXCLI" -ForegroundColor Yellow
$ESXCLI = Get-EsxCli -VMHost $_ -V2
# Install VIBs
Write-host "Installing VIB on $($_.Name)" -ForegroundColor Yellow
# Create Installation Arguments
$insParm = @{
viburl = $vibpath
dryrun = $false
nosigcheck = $true
maintenancemode = $false
force = $false
}
$action = $ESXCLI.software.vib.install.Invoke($insParm)
# Verify VIB installed successfully
if ($action.Message -eq "Operation finished successfully."){Write-host "Action Completed successfully on $($_.Name)" -ForegroundColor Green} else {Write-host $action.Message -ForegroundColor Red}
}