VMware Cloud Community
PSScripter
Enthusiast
Enthusiast
Jump to solution

Activate Clustered VMDK Support on all dastores in a cluster

Hello,

I need to do what the title says.

I asked this question to ChatGPT, and this is the answer returned. My question is, does this look like its valid to anyone? I was going to try it on a test DS, but curious on thought first.

 

# Get all datastores in the cluster
$datastores = Get-Datastore -Location (Get-Cluster)

# Loop through each datastore and enable clustered VMDK support
foreach ($datastore in $datastores) {
    $spec = New-Object VMware.Vim.HostDatastoreSystemVStorageObjectSpec
    $spec.operation = "enable"
    $spec.vStorageObject = $datastore.ExtensionData.Info.VStorageSupportObject
    $task = $datastore.ExtensionData.ConfigManager.DatastoreSystem.UpdateVStorageObject($spec)
    $task.WaitForCompletion()
}

 

Thanks!

 

Reply
0 Kudos
2 Solutions

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Yes, provided you are at least on vSphere 7.0.2 (see Get Clustered VMDK datastores - VMware Technology Network VMTN)

Try like this

Get-Datastore -PipelineVariable ds |
where{$_.Type -eq 'VMFS'} |
ForEach-Object -Process {
  if($ds.ExtensionData.Capability.ClusteredVmdkSupported){
    Get-View -Id $ds.ExtensionData.Host.Key -PipelineVariable esx |
    ForEach-Object -Process {
      $dsMgr = Get-View -Id $esx.ConfigManager.DatastoreSystem
      $dsMgr.EnableClusteredVmdkSupport($ds.ExtensionData.MoRef)
      Write-Host "Clustered VMDK enabled on $(ds.Name)"
    }
  }
  else{
    Write-Host "Clustered VMDK not supported on $(ds.Name)"
  }
}


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

View solution in original post

LucD
Leadership
Leadership
Jump to solution

I'm not 100% sure, but after browsing through the API Reference, I can't find a property to be used to determine if the feature is enabled or not.
Looks like the features is listed in the Capabilities (per ESXi node), and there are methods to Enable or Disable the feature, but nothing to show if it is enabled or not.


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

View solution in original post

7 Replies
LucD
Leadership
Leadership
Jump to solution

No, line 2 is already wrong.
The Location parameter on the Get-Datastore cmdlet only accepts Datacenter, Folder, and DatastoreCluster objects.

And I can see some other errors in the lines after that.


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

Reply
0 Kudos
PSScripter
Enthusiast
Enthusiast
Jump to solution

Is there anyway to script Enabling/Disabling Clustered VMDK Support on a datastore?

Thanks!

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Yes, provided you are at least on vSphere 7.0.2 (see Get Clustered VMDK datastores - VMware Technology Network VMTN)

Try like this

Get-Datastore -PipelineVariable ds |
where{$_.Type -eq 'VMFS'} |
ForEach-Object -Process {
  if($ds.ExtensionData.Capability.ClusteredVmdkSupported){
    Get-View -Id $ds.ExtensionData.Host.Key -PipelineVariable esx |
    ForEach-Object -Process {
      $dsMgr = Get-View -Id $esx.ConfigManager.DatastoreSystem
      $dsMgr.EnableClusteredVmdkSupport($ds.ExtensionData.MoRef)
      Write-Host "Clustered VMDK enabled on $(ds.Name)"
    }
  }
  else{
    Write-Host "Clustered VMDK not supported on $(ds.Name)"
  }
}


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

PSScripter
Enthusiast
Enthusiast
Jump to solution

How would one tweak this script to just show the status of this setting, and not actually change it

Thank you!

Reply
0 Kudos
PSScripter
Enthusiast
Enthusiast
Jump to solution

yes I was tried to remove that post because my version to check the status does not actually work 😞

I was looking to tweak it so I can check the status, but also get 1 entry for each DS.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

I cleaned up those last entries in the thread


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

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

I'm not 100% sure, but after browsing through the API Reference, I can't find a property to be used to determine if the feature is enabled or not.
Looks like the features is listed in the Capabilities (per ESXi node), and there are methods to Enable or Disable the feature, but nothing to show if it is enabled or not.


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