VMware Cloud Community
Virtualduty
Enthusiast
Enthusiast
Jump to solution

Get datastore with na id (Cannonical name)

Hello LuCD

Thank you for your help always, I am again making use of your very helpful script below 

Can you help me modify the below script to return corresponding Naa id of the datastore as well

&{$VCName = Read-Host "Enter the VC name "

Connect-VIServer VCname -WarningAction Continue

clear

Get-Cluster -PipelineVariable cluster |

Get-Datastore |

where {$_.name -notlike "*local*" -and $_.name -notlike "*template*"} |

Select @{N='Cluster';E={$cluster.Name}},Name,CapacityGB,FreespaceGB,@{N='UsedSpace';E={$_.FreeSpaceGB/$_.CapacityGB*100}}
} | Export-Csv report.csv -NoTypeInformation -UseCulture

Source: VMware PowerCLI Forum - VMware {code}

Thanks in advance !

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try like this

&{$VCName = Read-Host "Enter the VC name "

  Connect-VIServer VCname -WarningAction Continue

  clear

  Get-Cluster -PipelineVariable cluster |

  Get-Datastore |

  where {$_.name -notlike "*local*" -and $_.name -notlike "*template*"} |

  Select @{N='Cluster';E={$cluster.Name}},Name,CapacityGB,FreespaceGB,

    @{N='UsedSpace';E={$_.FreeSpaceGB/$_.CapacityGB*100}},

    @{N='CanonicalName';E={$_.ExtensionData.Info.Vmfs.Extent.DiskName -join '|'}}

} | Export-Csv report.csv -NoTypeInformation -UseCulture


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

Reply
0 Kudos
1 Reply
LucD
Leadership
Leadership
Jump to solution

Try like this

&{$VCName = Read-Host "Enter the VC name "

  Connect-VIServer VCname -WarningAction Continue

  clear

  Get-Cluster -PipelineVariable cluster |

  Get-Datastore |

  where {$_.name -notlike "*local*" -and $_.name -notlike "*template*"} |

  Select @{N='Cluster';E={$cluster.Name}},Name,CapacityGB,FreespaceGB,

    @{N='UsedSpace';E={$_.FreeSpaceGB/$_.CapacityGB*100}},

    @{N='CanonicalName';E={$_.ExtensionData.Info.Vmfs.Extent.DiskName -join '|'}}

} | Export-Csv report.csv -NoTypeInformation -UseCulture


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos