Last active
April 11, 2019 16:23
-
-
Save vexx32/e7ea9621d0beca06e9e2883f1a43fdb2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $PrimeNode = nslookup dockerhost.mycorp.com 192.168.31.67 | | |
| Select-String -Pattern Address | | |
| Where-Object LineNumber -eq 5 | | |
| ForEach-Object { $_.Line.Split(' ')[-1] } | |
| $SshData = ssh -q docker@$PrimeNode "cat /dns/zones/db.192.168.169" | | |
| Select-String -Pattern "\d{1,3}(\.\d{1,3}){3}" | |
| $IPList = $SshData -split '; ' | Select-String -Pattern "\d{1,3}(\.\d{1,3}){3}" | |
| $NodeList = foreach($IP in $IPList) { | |
| $server = ssh -q docker@$IP 'docker info' | | |
| Select-String -Pattern (' Data Space Used',' Data Space Total',' Data Space Available','Is Manager','Swarm','mycorp.com') | |
| $Node = $server -replace ':',' =' | ConvertFrom-StringData | |
| # Add the IP as an extra property so we keep all the data together. | |
| $Node.Add('IP', $IP) | |
| # Drop output here, it will be collected in $NodeList (above) after the loop completes. | |
| # The type cast turns the returned hashtable into a more conventional object for better display formatting. | |
| [PSCustomObject] $Node | |
| } | |
| # Print found nodes as a table | |
| $NodeList | Format-Table |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment