Skip to content

Instantly share code, notes, and snippets.



Last active Apr 11, 2019
What would you like to do?
$PrimeNode = nslookup |
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','')
$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