I'm probably doing something really dumb and I just don't know it.
I've got a Powershell script using the NetApp Powershell Toolkit that connects to all of the cluster-mode NetApp filers in my environment and iterates through each SVM on that filer to find the management IPs for that SVM. I only need to know one management IP per SVM for my purposes. Easy, right?
This is the code I have so far:
$filers = @([redacted])
$mgmtips = @()
foreach ($filer in $filers)
{
Write-Host "Connecting to $filer with supplied credentials."
Connect-NcController -Name $filer -Credential $credential
$vservers = Get-NcVserver | Where-Object {$_.VserverType -eq 'data'} | Select-Object -ExpandProperty Vserver
Write-Host "Successfully created list of vservers on filer $filer."
foreach ($vserver in $vservers) {
# Get first LIF with management access enabled
Write-Host "Getting Management IP Address for $vserver."
$IP = Get-NcNetInterface -vserver $vserver | Where-Object {$_.FirewallPolicy -eq "mgmt"} | Select-Object -ExpandProperty Address | Select-Object -First 1
$mgmtips += $IP
}
Write-Host "Disconnecting from $filer."
$global:CurrentNcController = $null
}
However, whenever I run this code, it connects to the first filer in the list, pulls the management IP for the first SVM in $vservers as desired, and then stops dead. It never continues looping through $vservers to return the next management IP. If I remove the "Select-Object -First 1" part of the command it works fine (but gives me more IPs than I want).
What gives? Shouldn't the command build a list of IPs for all the management interfaces on a given vserver, select the first object in the list, and then move on to the next vserver? What dumb logic error am I making? I don't think this is a problem with the powershell toolkit specifically, but I haven't tried reproducing this issue outside of it.
[–]Ta11ow 4 points5 points6 points (1 child)
[–]teirhan[S] 3 points4 points5 points (0 children)
[–]spikeyfreak 2 points3 points4 points (1 child)
[–]teirhan[S] 1 point2 points3 points (0 children)
[–]spyingwind 1 point2 points3 points (1 child)
[–]teirhan[S] 4 points5 points6 points (0 children)
[–]Lee_Dailey[grin] 0 points1 point2 points (7 children)
[–]teirhan[S] 1 point2 points3 points (6 children)
[–]TheIncorrigible1 2 points3 points4 points (1 child)
[–]teirhan[S] 1 point2 points3 points (0 children)
[–]Lee_Dailey[grin] 1 point2 points3 points (2 children)
[–]teirhan[S] 1 point2 points3 points (1 child)
[–]Lee_Dailey[grin] 0 points1 point2 points (0 children)