Funny, I was actually also looking for this exact same thing, which is how I found this.
To follow through with LucD's comment, I made a very slight modification to his script from the one he provided in another thread here -> #https://communities.vmware.com/thread/605539.
I tested it on 2 hosts last night and it worked.
You'd have to install the Posh-SSH module first (Find-Module Posh-SSH | Install-Module), and all the root passwords must be the same if you're running it against multiple ESXi hosts.
As always, thanks LucD. I'm sure you know how many thousands of people's careers you've saved
.
============================Individual ESXi host============================
$esxName = 'esxi_host_name'
$cred = Get-Credential -Message 'Enter credentials'
$cmdsub = @'
> /tmp/ams-bbUsg.txt
'@
$esx = Get-VMHost -Name $esxName
$session = New-SSHSession -ComputerName $esx.Name -Credential $cred –AcceptKey
$result = Invoke-SSHCommand -SSHSession $session -Command $cmdSub
Remove-SSHSession -SSHSession $session | Out-Null
============================Multiple ESXi hosts============================
$esxName = Get-Content -Path "C:\Path\to\textfilewithhostnames.txt"
$cred = Get-Credential -Message 'Enter credentials'
foreach($esxNames in $esxName)
{
$cmdsub = @'
> /tmp/ams-bbUsg.txt
'@
$esx = Get-VMHost -Name $esxNames
$session = New-SSHSession -ComputerName $esx.Name -Credential $cred –AcceptKey
$result = Invoke-SSHCommand -SSHSession $session -Command $cmdSub
Remove-SSHSession -SSHSession $session | Out-Null
}