PSScripter
Enthusiast
Enthusiast

This seems to work:

 

Connect-VIServer 'XXXXXXXXXXXXX'

$hosts = Get-Cluster -name "XXXXXXXXXXX" | Get-VMHost

$cred = Get-Credential
$cmd = "mv /vmfs/volumes/INF03-PMAX-NonProd-DS01/ucs-tool-esxi_1.2.1-1OEM.zip /tmp"
$cmd1 = "python /opt/ucs_tool_esxi/ucs_host_inventory.py"
$arguments = @{
    'VIBNAME' = '/tmp/ucs-tool-esxi_1.2.1-1OEM.zip'
}
    
foreach ($esx in $hosts) {

    Get-VMHost $esx | Get-VMHostService | Where-Object { $_.Key -eq "TSM-SSH" } | Start-VMHostService
    $session = New-SSHSession -ComputerName $esx -Credential $cred -AcceptKey
    Invoke-SSHCommand -SSHSession $session -Command $cmd

    $esxcli = Get-EsxCli -VMHost $esx
    $esxcli.software.vib.install("/tmp/ucs-tool-esxi_1.2.1-1OEM.zip")

    Invoke-SSHCommand -SSHSession $session -Command $cmd1 
    Remove-SSHSession -SSHSession $session | Out-Null 

}

 

Reply
0 Kudos