Forum Discussion
cvandal_163340
Nimbostratus
Jul 14, 2014Obtain Node Name by Node Description Using PowerShell
Hello,
Is it possible to obtain a node's name by looking at the node's description using PowerShell? Almost every node within our environment doesn't have a friendly node name however the descri...
Jul 16, 2014
Hi mate
Try this one?
Initialize Snapin
if ( (Get-PSSnapin | Where-Object { $_.Name -eq "iControlSnapIn"}) -eq $null ){
Add-PSSnapIn iControlSnapIn
}
Setup credentials
$User = "user"
$Password = "password"
$BigIP = "10.10.10.10"
Add a type/class to store the node data in
Add-Type @'
public class Node
{
public string Name;
public string IP;
public string Description;
public string Partition;
}
'@
Create an empty array to store the node objects in
$Nodes = @()
Connect to the BigIP and get an iControl Handle
$Success = Initialize-F5.iControl -HostName $BigIP -Username $User -Password $Password
$F5 = Get-F5.iControl
Get the partition list
$f5partitions = $f5.ManagementPartition
$partitionlist = $f5partitions.get_partition_list()
Loop through each partition saving node information
$partitionlist | foreach-object {
$Partition = $_.partition_name
$f5partitions.set_active_partition("Common")
$NodeNames = $f5.LocalLBNodeAddressV2.get_list()
$NodeIPs = $f5.LocalLBNodeAddressV2.get_address($NodeNames)
$NodeDescriptions = $f5.LocalLBNodeAddressV2.get_description($NodeNames)
for($i=0;$i -lt ($NodeNames.Count);$i++){
$objTempNode = New-Object Node
$objTempNode.Name = $NodeNames[$i]
$objTempNode.IP = $NodeIPs[$i]
$objTempNode.Description = $NodeDescriptions[$i]
$objTempNode.Partition = $Partition
$Nodes += $objTempNode
}
}
That will store your node information in $Nodes. You can filter by using ie. where-object:
$nodes | Where-Object { $_.description.Contains("WEB") }
Hope that's what you're looking for?
Kind regards, Patrik
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects