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
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
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
Thank you very much for your reply. Solved.