VMware Cloud Community
Haribcs
Contributor
Contributor
Jump to solution

Rescan VMfs

HI Luc, 

 

When we are creating new datastore, we are scanning ~40 esxi hosts. i'm using get-vmhoststorage -vmhost $hostlist -rescanvmfs. The problem is it is executing the command one host per time(15Seconds/Host).

 

Im using Powershell Core 7 and 12.2.0.17. Is there any method to run vmfsrescan all host at the same time?

like foreach -parallel {}

 

Thanks in advance. 

 

 

Labels (1)
Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Sure, you could do something like this (it assumes you are already connected to the VCSA).

$vc = $global:defaultviserver

Get-Cluster -Name cluster | Get-VMHost |
ForEach-Object -Parallel {
  Get-VMHostStorage -VMHost $_ -Server $using:vc -RescanVmfs
}

The snippet uses all the ESXi nodes in a cluster, but you can easily change that to any collection of ESXi nodes.


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

View solution in original post

1 Reply
LucD
Leadership
Leadership
Jump to solution

Sure, you could do something like this (it assumes you are already connected to the VCSA).

$vc = $global:defaultviserver

Get-Cluster -Name cluster | Get-VMHost |
ForEach-Object -Parallel {
  Get-VMHostStorage -VMHost $_ -Server $using:vc -RescanVmfs
}

The snippet uses all the ESXi nodes in a cluster, but you can easily change that to any collection of ESXi nodes.


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