Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Hope you can help.
I want to get the IP address of a SVM's cifs lif into a variable and use this variable in Test-Path, but I can't work out what's happening:
$newshare = share_test
$activevserverip = Get-NcNetInterface -Vserver $activevserver -DataProtocols cifs | Select-Object Address
PS C:\Windows\system32> $activevserverip
Address
-------
xxx.xxx.21.10
Test-Path "\\$activevserverip\$newshare" -verbose
False
I receive a 'false' even though I know the path is up and accessible. What am I doing wrong please? Is it something like the data type of the IP address? If I create a path variable the IP address details are enclosed in a hash table (?). How can I reduce it to just the IP address?
PS C:\Windows\system32> $path = "\\$activevserverip\$newshare"
PS C:\Windows\system32> $path
\\@{Address=xxx.xxx.21.10}\share_test
Sorry if this is basic
Thanks
Solved! See The Solution
1 ACCEPTED SOLUTION
tyrone_owen_1 has accepted the solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Use as
Test-Path "\\$($activevserverip.address)\$newshare" -verbose
Gidi Marcus (Linkedin) - Storage and Microsoft technologies consultant - Hydro IT LTD - UK
4 REPLIES 4
tyrone_owen_1 has accepted the solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Use as
Test-Path "\\$($activevserverip.address)\$newshare" -verbose
Gidi Marcus (Linkedin) - Storage and Microsoft technologies consultant - Hydro IT LTD - UK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Brilliant, thank you.
I can see why that works, however I'm not sure why the below doesn't filter down to just the address:
>$activevserverip = Get-NcNetInterface -Vserver $activevserver -DataProtocols cifs | Select-Object Address
>activevserverip
Address
-------
10.4.0.9
Any links that you could share which would explain this please?
Thanks again
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
As in the example below you can get the type by piping the output to GM (get-member).
With using only the "select" - you still have it in a structured data type (in my get-disk example below "Selected.Microso...."), As test-parh don't know this odd data-type , you have to extract it into a format it expects (can see in get-help test-path it expects a string).
PS C:\Users\g> get-help Test-Path
NAME
Test-Path
SYNTAX
Test-Path [-Path] <string[]> [-Filter <string>]..........
PS C:\Users\g> Get-Disk | select FriendlyName | gm
TypeName: Selected.Microsoft.Management.Infrastructure.CimInstance
Name MemberType Definition
---- ---------- ----------
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
FriendlyName NoteProperty string FriendlyName=INTEL SSDSC2BF180A5L
PS C:\Users\g> (Get-Disk).FriendlyName
INTEL SSDSC2BF180A5L
PS C:\Users\g> (Get-Disk).FriendlyName | gm
TypeName: System.String
Name MemberType Definition
---- ---------- ----------
Clone Method System.Object Clone(), System.Object ICloneable.Clone()
.......
Gidi Marcus (Linkedin) - Storage and Microsoft technologies consultant - Hydro IT LTD - UK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the additional info - very helpful
