Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #################################################################################################
- #
- # Generates a table with the db variables
- #
- #################################################################################################
- #Setup Credentials
- $user = ''
- $pass = ''
- #Array with the IP's of the load balancers you want to compare
- #Example: @("10.0.0.1", "192.168.1.1")
- $BigIPs = @();
- $ResultFile = ".\db.html"
- ################################################################################################
- # End config
- ################################################################################################
- if ( (Get-PSSnapin | Where-Object { $_.Name -eq "iControlSnapIn"}) -eq $null ){
- Add-PSSnapIn iControlSnapIn
- }
- #Enable TLS1.2
- [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
- $bigipdict = @{}
- $MasterKeyList = @()
- $HTML = ""
- #Get db key/value from all load balancers
- for($i=0;$i -lt $BigIPs.count;$i++){
- $Success = Initialize-F5.iControl -HostName $BigIPs[$i] -Username $user -Password $pass
- $IC = Get-F5.iControl
- $IC.ManagementPartition.set_active_partition('Common')
- $BigDB = $ic.ManagementDBVariable.get_list()
- $bigipdict.Add($BigIPs[$i], $BigDB)
- $MasterKeyList += (Compare-Object $MasterKeyList $BigDB.name).InputObject
- }
- $HTML = @"
- <table>
- <tr>
- <td> </td>
- "@
- for($i=0;$i -lt $BigIPs.count;$i++){
- $HTML += @"
- <td>$($BigIPs[$i])</td>
- "@
- }
- $HTML += @"
- </tr>
- "@
- Foreach($Key in $MasterKeyList){
- $HTML += @"
- <tr>
- <td>$Key</td>
- "@
- for($i=0;$i -lt $BigIPs.count;$i++){
- $value = $bigipdict[$BigIPs[$i]] | Where-Object{ $_.name -eq $Key }
- if($value){
- $HTML += @"
- <td>$($value.value)</td>
- "@
- } else {
- $HTML += @"
- <td>N/A</td>
- "@
- }
- }
- $HTML += @"
- </tr>
- "@
- }
- $HTML += @"
- </table>
- "@
- $HTML | Out-File $ResultFile
Advertisement
Add Comment
Please, Sign In to add comment