VMware Cloud Community
andysza01
Contributor
Contributor

help with foreach loop - PowerCLI

Hello, all

The foreach loop listed below was downloaded from this amazing community, and I have been using it to mount datastores in a DR site. It has been working fine! But the problem is, the loop below will only work with one ESXi host per time, and then I need your help with a new foreach loop fuction to execute the same command listed below but in all ESXi hosts members of my cluster. I have been trying different ways but unfortunately without success.

You help is really appreciated!

$esxHosts = Get-VMHost -Location $cluster | Sort Name

foreach ($vmfs in $esxcli.storage.vmfs.snapshot.list())

{

     $esxcli.storage.vmfs.snapshot.mount($false, $vmfs.VolumeName, $null)

}

Regards,

0 Kudos
0 Replies