PowerCLI

 View Only
  • 1.  Powercli to set DataStore Reclaim Rate

    Posted Jun 29, 2023 06:48 PM

    Hello,

    Is there a way to set datastore space reclamation rate via PowerCli? I looked number of examples but they all mention about setting via esxcli.  I am looking to set the space reclamation rate from 100 MB/s to 400 MB/s? for number of datastores.

     

    Thank you



  • 2.  RE: Powercli to set DataStore Reclaim Rate
    Best Answer

    Posted Jun 29, 2023 07:05 PM

    You can use all esxcli commands through the Get-EsxCli cmdlet.



  • 3.  RE: Powercli to set DataStore Reclaim Rate

    Posted Jul 11, 2023 12:27 PM

    Would be great to have some more of that . 

    PowerCLI and Datastore ( Reclamation ) , there is not to much content from "Mister Google" and "Mister ChatGPT" is not currently answering  

    Mayb   has a Link he can Post . 

    What would be the Synthax to use something like 

    esxcli storage vmfs reclaim config set --volume-label datastore_name --reclaim-method fixed -b 100

    with PowerCLI ? 


    https://docs.vmware.com/en/VMware-vSphere/7.0/com.vmware.vsphere.storage.doc/GUID-AAEB5C55-A815-4F9D-94C0-5B9B5167DFD8.html



  • 4.  RE: Powercli to set DataStore Reclaim Rate

    Posted Jul 11, 2023 12:35 PM


  • 5.  RE: Powercli to set DataStore Reclaim Rate

    Posted Jul 11, 2023 12:52 PM

    If that would help yes , but I run into error like the other User in the Thread. 

    So thanks for the Answer, but It would be nice to pole all Datastores 

    Like that ( from someone else, which provide Infos to the Datastores ) 


    $Datastores = Get-Datastore
    foreach($DS in $Datastores)
    {
    $DSInfo = $DS.ExtensionData.Info

    if($DSInfo -is [VMware.Vim.VmfsDatastoreInfo] -and $DSInfo.Vmfs.MajorVersion -eq 6)
    {$DSInfo.Vmfs | select Name, BlockSizeMb,Version, UnmapPriority, UnmapGranularity, Uuid, Extent}

    else {
    $prop = [ordered]@{Name = $DSInfo.vmfs.Name
    BlockSizeMb = $DSInfo.Vmfs.BlockSizeMb
    Version = $dsinfo.vmfs.Version
    UnmanPriority = "VMFS Version is below 6"
    UnmapGranularity = "VMFS version is below 6"
    }
    New-Object -TypeName psobject -Property $prop | ft -AutoSize
    }
    }

    And then have the ability to change Unmap Priority in a Bulk. 

     



  • 6.  RE: Powercli to set DataStore Reclaim Rate

    Posted Jul 11, 2023 12:59 PM

    Not sure I understand what you are trying to do.
    That script just lists the datastores, where does the unmap come into play?
    And what do you mean by "change Unmap Priority in a Bulk"



  • 7.  RE: Powercli to set DataStore Reclaim Rate

    Posted Jul 11, 2023 03:53 PM

    "change Unmap Priority in a bulk"  sorry , maybe that is wrong english . 

    I try identify all those Datastores which have a UnmapPriority "none" and change the UnmapPriority then to "low" . 

    If the UnmapPriority is "none" there will be no Space Reclamation going on , if it is "low" Reclamation rate is around 100 MB/s 




  • 8.  RE: Powercli to set DataStore Reclaim Rate

    Posted Jul 11, 2023 06:02 PM

    Something along these lines

    Get-Datastore -PipelineVariable ds |
    Where{$ds.Type -eq 'VMFS'} |
    ForEach-Object -Process {
       $obj = [ordered]@{
          Name = $ds.Name
          BlockSizeMb = $ds.ExtensionData.Info.Vmfs.BlockSizeMb
          Version = $ds.ExtensionData.Info.Version
          UnmanPriority = ''
          UnmapGranularity = ''
          Uuid = $ds.ExtensionData.Info.Uuid
       }
       if (([version]$ds[0].FileSystemVersion).Major -lt 6) {
          $obj.UnmapPriority = "VMFS Version is below 6"
          $obj.UnmapGranularity = "VMFS version is below 6"
       }
       else{
          $obj.UnmapPriority = $ds.ExtensionData.Info.Vmfs.UnmanPriority
          $obj.UnmapGranularity = $ds.ExtensionData.Info.Vmfs.UnmapGranularity
    
          if ($ds.ExtensionData.Info.Vmfs.UnmapPriority -eq 'none'){
             $esx = Get-VMHost | Get-Random -Count 1
             $esxcli = Get-EsxCli -VMHost $esx -V2
             $arguments = $esxcli.storage.vmfs.reclaim.config.set.CreateArgs()
             $arguments.volumelabel = $ds.Name
             $arguments.reclaimmethod = 'fixed'
             $arguments.reclaimpriority = 'low'
             $arguments.reclaimbandwidth = 100
             $esxcli.storage.vmfs.reclaim.config.set.Invoke($arguments)
          }
       }
    }
    
    


  • 9.  RE: Powercli to set DataStore Reclaim Rate

    Posted Jul 11, 2023 10:59 PM

    Thanks .. for solving the puzzel