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 = $store.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
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.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
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.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
hats worked. THANKS!