Thank you for taking time (what, it's almost 02:00 a clock in Belgium, don't you sleep ever?).
I like your oneliners in orders to retrieve these properties. They are correct syntatically (if i use them outside of this script) but for some reason they end up with errors inside this script. I suspect that it has to do with the way how the loop for datastore is defined and every time when i try to call something by utilizing .extensiondata then it fails with The argument is null or empty.
I guess this part of a script already does get-view which makes the .extensiondata not usable.
$VMHost | Get-DataStore | Where-Object { $_.Name -notlike "*local*"} | Sort-Object Name | get-view | %{
$row = "" | Select-Object Rec_ID, ScanDate, ScanTime, Infra, vCenter, Datacenter,
The following error message is something i get every time i try to utilize .extensiondata.
Get-View : Cannot validate argument on parameter 'VIObject'. The argument is null or empty.Supply an argument that is not null or empty and then try the command again.
At scriptname.ps1<line #> char:<char#>
+ $row.VMsHosted= [string]::Join("|",(Get-View <<<< $dst.ExtensionData.VM | %{$_.Name}))
+ CategoryInfo : InvalidData: (:) [Get-View], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutom
ation.ViCore.Cmdlets.Commands.DotNetInterop.GetVIView
And about LUN uuid:
i'm using this one but it's so slow. I was looking for something faster that might integrate with this script.
function GetLunUUID([string]$vmhost,[string]$dsname) {
$ds = Get-View (Get-View (Get-VMHost -Name $vmhost).ID).ConfigManager.StorageSystem
foreach ($vol in $ds.FileSystemVolumeInfo.MountInfo) {
if ($vol.Volume.Name -eq $dsname) {
# Write-host "DS Name:`t" $vol.Volume.Name
# Write-host "VMFS UUID:`t" $vol.Volume.Uuid
foreach ($volid in $vol.Volume.Extent) {
foreach ($lun in $ds.StorageDeviceInfo.MultipathInfo.Lun){
if ($lun.Id -eq $volid.DiskName) {
break
}
}
}
# Write-Host "LUN Name:`t" $lun.ID
$mid = $lun.ID
foreach ($id in $ds.StorageDeviceInfo.ScsiLun) {
if ($id.CanonicalName -eq $mid) {
$uuid = $id.Uuid
# Write-host "LUN UUID:`t" $uuid
}
}
}
}
return $uuid
}
O;-), and i saw you script with datastores view at: http://www.lucd.info/2011/11/14/storage-views-datastores/.
After this i will try to pick up some addtional properties that you offer in that script. Great!