I need to fetch NIC name from Public IP.I am stuck at fetching NIC name from IP configuration.
I've IP configuration of PIP as:
/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx/resourceGroups/NetworkWatcherRG/providers/Microsoft.Network/networkInterfaces/testnic/ipConfigurations/ipconfig1
$ip.IpConfiguration.Id.tostring().Substring($ip.IpConfiguration.Id.ToString().LastIndexOf('/')+1)
I expect output as 'testnic' but it's giving me output 'ipconfig1'
$...Substring()...
line? If$ip.IpConfiguration.Id
is the value you posted above then that's obviously going to return you the string after the final /, i.e. ipconfig1, because that's what your Substring and LastIndexOf do. Or did you mean you expected$ip.IpConfiguration.Id
to give you 'testnic'? – Rup$ip.IpConfiguration.Id.tostring().Split('/')[-3]
– iRon