View Only
  • 1.  Listing Datastore device name

    Posted Jun 12, 2014 08:45 AM

    Need help with this simple script

    $datastores = Get-Datastore -Location "CXXX" | Where-Object {$_.ExtensionData.Info.GetType().Name -eq "VmfsDatastoreInfo"}

    $myColCurrent = @()

    ForEach ($store in $datastores)


      $myObj = "" | Select-Object Name, devicename

       $myObj.Name = $

      Write-Host $myObj.Name

      $myObj.devicename = $store.ExtensionData.Info.Vmfs.Extent.DiskName

      Write-Host $myObj.devicename

    the datastore name is writtenl correctly but the devicename is blank and get this warning:

    WARNING: The 'Accessible' property of Datastore type is deprecated. Use the 'State' property instead.

    Strange part is the Script works lab powercli connecting to the lab vcenter. But, gives the error in production powecli server to prod vcenter.  the powercli and vcenter server versions are the same.

    A help is greatly appreciated

  • 2.  RE: Listing Datastore device name
    Best Answer

    Posted Jun 12, 2014 08:55 AM

    The Extent property is an array.

    Try changing this line

    $myObj.devicename = $store.ExtensionData.Info.Vmfs.Extent.DiskName

    into this

    $myObj.devicename = [string]::Join(',',($store.ExtensionData.Info.Vmfs.Extent | %{$_.DiskName}))

    You can safely ignore the warning messages, or perhaps disable them with the Set-PowerCLIConfiguration cmdlet and the DisplayDeprecationWarnings switch.

  • 3.  RE: Listing Datastore device name

    Posted Jun 13, 2014 05:50 AM

    hats worked. THANKS!