2 Replies Latest reply on Jan 15, 2013 12:49 PM by LucD

    Query for Unformatted Luns

    jcouch Enthusiast

      Looking for a way to query a vcenter for unformatted volumes. I found this script on Luc's site, but it looks like the ConfigManager.StorageSystem only looks at luns that have VMFS on them. Any suggestions?

       

      http://www.lucd.info/2010/06/26/create-vmfs-datastores-on-a-free-space-partition/

       

      Thanks,
      Jeff

        • 1. Re: Query for Unformatted Luns
          LucD Guru
          Community WarriorsvExpertUser Moderators

          With a smal change that function can return free LUNs.

          Something like this

           

          function Get-FreeScsiLun {
            param (
            [parameter(ValueFromPipeline = $true,Position=1)]
            [ValidateNotNullOrEmpty()]
            [VMware.VimAutomation.Client20.VMHostImpl]
            $VMHost  )
          
            process{
              $storMgr = Get-View $VMHost.ExtensionData.ConfigManager.DatastoreSystem
              $storMgr.QueryAvailableDisksForVmfs($null) | %{
                New-Object PSObject -Property @{
                  VMHost = $VMHost.Name
                  CanonicalName = $_.CanonicalName
                 
          Uuid = $_.Uuid
                 
          CapacityGB = [Math]::Round($_.Capacity.Block * $_.Capacity.BlockSize / 1GB,2)       }     }   } } Get-VMHost MyEsx | Get-FreeScsiLun
          • 2. Re: Query for Unformatted Luns
            jcouch Enthusiast

            As always, Thank you sir!