Automation

 View Only
  • 1.  Export a list of NFS-Datastores attached to a Cluster

    Posted Oct 05, 2011 02:10 PM

    Hi,

    i´m searching for a little script that generates an output (table? / csv?) of the Datastores ( NFS ) attached to a cluster.

    I want the script to show

    Datastore-Name

    NFS-Server

    path ( on NFS-Server )

    How has such a script to look like?

    Thx

    Chakoe



  • 2.  RE: Export a list of NFS-Datastores attached to a Cluster

    Posted Oct 05, 2011 02:23 PM

    Try something like this

    $report = foreach($cluster in Get-Cluster){
        Get-Datastore -Entity (Get-VMHost -Location $cluster) | 
        where {$_.Type -eq "NFS"} |
        Sort-Object -Unique |
        Select @{N="Cluster";E={$cluster.Name}},Name,RemoteHost,RemotePath
    }
    $report | Export-Csv "C:\NFS-datastores.csv" -NoTypeInformation -UseCulture

    If you want it for a specific cluster change the first line into

    $report = foreach($cluster in (Get-Cluster -Name MyCLuster)){
    


  • 3.  RE: Export a list of NFS-Datastores attached to a Cluster

    Posted Oct 05, 2011 02:43 PM

    Luc,

    this reports the same results as the simple Get-Datastore. Means: Only Name, FreeSpaceMB and CapacityMB are shown with values. RemoteHost and RemotePath are still empty



  • 4.  RE: Export a list of NFS-Datastores attached to a Cluster

    Posted Oct 05, 2011 05:45 PM
      |   view attached

    Are you sure you copied the script correctly ?

    Works fine for me and shows the Remote Host and Path.

    I'll attach the script to make sure you have the correct copy.

    Attachment(s)

    ps1
    NFS-datastore-report.ps1   317 B 1 version


  • 5.  RE: Export a list of NFS-Datastores attached to a Cluster

    Posted Oct 06, 2011 05:52 AM

    Good morning,

    the Script is:

    $report = foreach($cluster in Get-Cluster -Name Cluster23){
        Get-Datastore -Entity (Get-VMHost -Location $cluster) |
        where {$_.Type -eq "NFS"} |
        Sort-Object -Unique |
        Select @{N="Cluster";E={$cluster.Name}},Name,RemoteHost,RemotePath
    }
    $report | Export-Csv "C:\NFS-datastores.csv" -NoTypeInformation -UseCulture

    And its output in the csv is:

    "Cluster";"Name";"RemoteHost";"RemotePath"
    "Cluster23";"Cluster23_01";;
    "Cluster23";"Cluster23_02";;
    "Cluster23";"Cluster23_03";;
    "Cluster23";"Cluster23_04";;
    "Cluster23";"Cluster23_05";;
    "Cluster23";"Cluster23_06";;
    "Cluster23";"Cluster23_GW_RZ2_1";;

    So, whats going wrong? For example, here are the Values ( in VI-Client) of the Datastore Cluster23_01

    Identification:          Cluster23_01

    Server:                    10.17.1.251

    Path:                       /qvm03_001



  • 6.  RE: Export a list of NFS-Datastores attached to a Cluster
    Best Answer

    Posted Oct 06, 2011 06:23 AM

    Wait a minute, which PowerCLI version are you using ?

    Do a

    Get-PowerCLIVersion

    If I remember correctly these properties are new in PowerCLI 5



  • 7.  RE: Export a list of NFS-Datastores attached to a Cluster

    Posted Oct 06, 2011 06:49 AM

    Had the same idea :-)

    just upgaded to Version 5 et voila :-)

    Thx a lot!