VMware Cloud Community
Janani0711
Contributor
Contributor

Script to get the advanced setting for multiple ESXi servers

Hi,

 

We have 200+ ESXi servers in our environment. We need to apply the storage related settings succh as NFS.MaxQueueDepth,NFS.MaxVolumes ,SunRPC.MaxConnPerIP to each host. Before applying, we need to get the ESXi hosts which require the settings and then apply. could you please help with the script?

0 Kudos
1 Reply
LucD
Leadership
Leadership

These advanced settings are normally present with the default values.
Do you want to look for those that have the default settings?

If yes, you could do something like this

$adv = @{
  'NFS.MaxQueueDepth' = 4294967295
  'NFS.MaxVolumes' = 32
  'SunRPC.MaxConnPerIP' = 32
}

Get-VMHost -PipelineVariable esx |
ForEach-Object -Process {
  $result = $adv.GetEnumerator() | ForEach-Object -Process {
    (Get-AdvancedSetting -Name $_.Name -Entity $esx).Value -eq $_.Value
  }
  if($result -contains $false){
    $obj = [ordered]@{
      VMHost = $esx.Name
    }
    $adv.GetEnumerator() | ForEach-Object -Process {
      $obj.Add($_.Name, (Get-AdvancedSetting -Name $_.Name -Entity $esx).Value)
    }
    New-Object -TypeName PSObject -Property $obj
  }
}


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

0 Kudos