VMware Cloud Community
bvi1006
Enthusiast
Enthusiast
Jump to solution

Get-Datastore - need Location (which is actually the netfs information

Hi,

I would like to get the "location" for the datastore which can be found in the VCenter GUI under summary. Does anyone know how to get that?
Thanks!

1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Not really I'm afraid.

I would fetch the IP address, do the lookup and replace the IP.

Something like this perhaps

$text = "netfs://10.x.x.x//vol/vol_name_01/vm_name_01/"
$array = $text.Split('/')
$array[2] = [System.Net.Dns]::GetHostByAddress([IpAddress]$array[2]).HostName.Split('.')[0]
[
string]::Join('/',$array)


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

View solution in original post

Reply
0 Kudos
4 Replies
LucD
Leadership
Leadership
Jump to solution

Try something like this

Get-Datastore | Select Name,@{N="Location";E={$_.ExtensionData.Info.Url}}


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

bvi1006
Enthusiast
Enthusiast
Jump to solution

Thanks Luc.

I am using this statement which gives me the location, but I need the name of the filer, not the IP...

@{N="Location";E={$datastore.ExtensionData.Info.Url}}

The result is:

netfs://10.x.x.x//vol/vol_name_01/vm_name_01/

Now someone wants me to replace the IP with the actual filer name. Any quick ideas on how to do this? I know I can strip it, probably do an nslookup, then add it back in, but that sounds like a lot of work! Smiley Happy

Thanks

LucD
Leadership
Leadership
Jump to solution

Not really I'm afraid.

I would fetch the IP address, do the lookup and replace the IP.

Something like this perhaps

$text = "netfs://10.x.x.x//vol/vol_name_01/vm_name_01/"
$array = $text.Split('/')
$array[2] = [System.Net.Dns]::GetHostByAddress([IpAddress]$array[2]).HostName.Split('.')[0]
[
string]::Join('/',$array)


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

Reply
0 Kudos
bvi1006
Enthusiast
Enthusiast
Jump to solution

Excellent, thanks Luc!

Reply
0 Kudos