VMware Cloud Community
dampfross
Contributor
Contributor
Jump to solution

Check for *.vib in a path

Tried to list all upgrade files in a path

I store the actual update  vibs in a folder called Update. So I want to update the esxi with a script but Get-Childitem returns simply nothing.

$VMHost = "ESXi"
Connect-VIServer $VMHost
$esxcli = Get-ESXcli -VMHost $VMHost

$ds = Get-Datastore "STORE"
$Path = $ds.DatastoreBrowserPath + "\Update\"

$Files = Get-ChildItem -Recurse -Path $Path | sort

if ($Files.Count -gt 0) {

    Foreach ($File in $Files) {
        $esxcli.software.vib.install($File)
    }
}

How can I get the right path to update the esxi?

Thank you for any help

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

You could do something like this.
Remove the 'dryrun' property from the hash table, or set it to $false, when you are sure the script is working correctly.

$VMHost = "ESXi"
Connect-VIServer $VMHost
$esxcli = Get-ESXcli -VMHost $VMHost -V2

$ds = Get-Datastore "STORE"
$Path = $ds.DatastoreBrowserPath + "\Update\"

$Files = Get-ChildItem -Recurse -Path $Path | Sort-Object

if ($Files.Count -gt 0) {
    Foreach ($File in $Files) {
        $path = "$($ds.ExtensionData.Info.Url -replace 'ds://','')/$($File.DatastoreFullPath.Split(' ')[1])"
        $esxcli.software.vib.install.Invoke(@{viburl=$path;dryrun=$true})
    }
}

 


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

Reply
0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

You could do something like this.
Remove the 'dryrun' property from the hash table, or set it to $false, when you are sure the script is working correctly.

$VMHost = "ESXi"
Connect-VIServer $VMHost
$esxcli = Get-ESXcli -VMHost $VMHost -V2

$ds = Get-Datastore "STORE"
$Path = $ds.DatastoreBrowserPath + "\Update\"

$Files = Get-ChildItem -Recurse -Path $Path | Sort-Object

if ($Files.Count -gt 0) {
    Foreach ($File in $Files) {
        $path = "$($ds.ExtensionData.Info.Url -replace 'ds://','')/$($File.DatastoreFullPath.Split(' ')[1])"
        $esxcli.software.vib.install.Invoke(@{viburl=$path;dryrun=$true})
    }
}

 


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
dampfross
Contributor
Contributor
Jump to solution

Thank you very much  for your reply. Solved.

Reply
0 Kudos