need some assistance with getting nfs datastores information. path/remote host address or name/capacity/free space. can this be done with a oneliner? thank you in advance.
This truncation of output is a PowerShell feature. PS, by default, wants to place the output in a tabular format and wants to make sure that all the output columns fit in the width of your screen.
That's why some output appears to be truncated on the screen.
You can find a more complete explanation here in Tobias Weltner's "Mastering PowerShell" series.
There are several ways of getting the complete properties in your output.
You could use the Format-Table cmdlet with the -Wrap parameter.
Get-Datastore | where {$_.type -eq "NFS"} | Get-View | select @{N="Host"; E={$_.Info.Nas.RemoteHost}}, @{N="Path"; E={$_.Info.Nas.RemotePath}}, @{N="Capacity"; E={$_.Info.Nas.Capacity}}, @{N="Free"; E={$_.Info.FreeSpace}} | ft -Wrap
See for other methods.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Sure can.
Get-Datastore | where {$_.type -eq "NFS"} | Get-View | select @{N="Host"; E={$_.Info.Nas.RemoteHost}}, @{N="Path"; E={$_.Info.Nas.RemotePath}}, @{N="Capacity"; E={$_.Info.Nas.Capacity}}, @{N="Free"; E={$_.Info.FreeSpace}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Wow! Excellent, only thing is my path is about 28 character long and was truncated. Thanks LucD!
This truncation of output is a PowerShell feature. PS, by default, wants to place the output in a tabular format and wants to make sure that all the output columns fit in the width of your screen.
That's why some output appears to be truncated on the screen.
You can find a more complete explanation here in Tobias Weltner's "Mastering PowerShell" series.
There are several ways of getting the complete properties in your output.
You could use the Format-Table cmdlet with the -Wrap parameter.
Get-Datastore | where {$_.type -eq "NFS"} | Get-View | select @{N="Host"; E={$_.Info.Nas.RemoteHost}}, @{N="Path"; E={$_.Info.Nas.RemotePath}}, @{N="Capacity"; E={$_.Info.Nas.Capacity}}, @{N="Free"; E={$_.Info.FreeSpace}} | ft -Wrap
See for other methods.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Had the same problem and fixed it with www.pathtoolong.com
Is it possible to include the host/cluster? with the Get-VMhost command?
This adds the ESX hostname and the clustername.
If the NFS export is mounted on all ESX hosts in a cluster you will see a line per ESX host in the output.
$report = @() Get-Datastore | where {$_.type -eq "NFS"} | Get-View | %{ $ds = $_ $_.Host | %{ $row = "" | Select NFSHost, Path, Capacity, Free, ESXHost, Cluster $row.NFSHost = $ds.Info.Nas.RemoteHost $row.Path = $ds.Info.Nas.RemotePath $row.Capacity = $ds.Info.Nas.Capacity $row.Free = $ds.Info.FreeSpace $row.ESXHost = (Get-View $_.Key).Name $row.Cluster = (Get-Cluster | where {$_ | Get-VMHost | where {$_.Name -eq $row.ESXHost}}).Name $report += $row } } $report | Sort-Object -property Cluster, ESXHost | ft -wrap
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference