Is there a PowersCli cmdlet that allows for copying a directory/files to multple ESXi hosts? I'm looking to drop the latest version of vmTools on all 90 hosts across multiple clusters. I guess I could use scp if I needed to but I was hoping to find something more automated.
Thanks in advance!
Thanks, LucD!
For anyone interested, I created the below script based off of LucD's suggestion of the Posh-SSH module - it seems that the command to copy out an entire directory was dropped and so I instead put each individual file into an array and copied them over in a foreach loop.
Install-Module -Name Posh-SSH
$credential = Get-Credential
$ProgressCounter = 0
$Hosts = Get-Content D:\Temp\ServerList.txt
$Files = gci D:\Temp\vmTools\vmtools_12.3.0\ | % { $_.FullName }
foreach ($ESXhost in $Hosts){
$ProgressCounter = 0
foreach ($File in $Files) {
Set-SCPItem -ComputerName $ESXhost -Credential $credential -Path $File -Destination '/productLocker/vmtools/' -AcceptKey
Write-Host "Copying $File to $ESXhost"
$ProgressCounter++
Write-Progress -Activity "Copying Files" -Status "Progress: $ProgressCounter/$($Files.count)" -PercentComplete (($ProgressCounter / $Files.count) *100)
}
}
I assume you mean copying newer versions of the VMware Tools ISO files?
If yes, there is no cmdlet for that afaik.
But you can automate SCP commands easily with the cmdlets from the Posh-SSH module.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks, LucD!
For anyone interested, I created the below script based off of LucD's suggestion of the Posh-SSH module - it seems that the command to copy out an entire directory was dropped and so I instead put each individual file into an array and copied them over in a foreach loop.
Install-Module -Name Posh-SSH
$credential = Get-Credential
$ProgressCounter = 0
$Hosts = Get-Content D:\Temp\ServerList.txt
$Files = gci D:\Temp\vmTools\vmtools_12.3.0\ | % { $_.FullName }
foreach ($ESXhost in $Hosts){
$ProgressCounter = 0
foreach ($File in $Files) {
Set-SCPItem -ComputerName $ESXhost -Credential $credential -Path $File -Destination '/productLocker/vmtools/' -AcceptKey
Write-Host "Copying $File to $ESXhost"
$ProgressCounter++
Write-Progress -Activity "Copying Files" -Status "Progress: $ProgressCounter/$($Files.count)" -PercentComplete (($ProgressCounter / $Files.count) *100)
}
}