I want to use the following powershell code to iterate through a collection of IP addresses and check whether they have a DNS entry in InfoBlox.
Set-IBConfig -ProfileName 'MyGrid' -WAPIHost dns.xx.xxx -WAPIVersion latest -
Credential (Get-Credential) -SkipCertificateCheck
$resultsFolder = "C:\Users\x\Documents\20220920"
$AviClusterList = 'C:\Users\x\Documents\20220920\AviCluster.csv'
$AviClusters = Import-csv $AviClusterList
foreach ($AviCluster in $AviClusters) {
$AviClusterName = $AviCluster.FQDN
$SEVirtualIPs = Import-Csv "$resultsFolder\$AviClusterName.csv"
foreach($SEVirtualIP in $SEVirtualIPs){
try {
$ipObj = Get-IBObject -type ipv4address -filters
'status=USED',"ip_address=$($SEVirtualIP.'Service Engine Virtual IPs')"
}
catch {
"A network was not found for this address"
}
$ipObj `
| select ip_address `
| Select-Object *,@{n="Infoblox Reservation Name";e={$ipObj.names}} `
| Select-Object *,@{n="Status";e={$ipObj.status}} `
| Select-Object *,@{n="In Conflict";e={$ipObj.is_conflict}} `
| Export-csv -Path "$resultsFolder\AviVirtualIPReservations.csv" -append -NoTypeInformation -Force
}
}
Currently I have Catch
statement above. I would like to get that catch
statement added to the export CSV against the IP. That way I know what IP reservation doesn't have a network.