Creating objects on ASA from a file of IPs and Putting then in an object group (CLI)

Power Shell Script (Run it straight from powershell prompt/file must be in the same directory):

ASA:
object-group network Log4j_BadIP_Grp

foreach($ip in Get-Content ip1.txt)
{
Write-output “object network Log4j_BadIP_$ip” | Tee-Object -FilePath ‘C:\Users\fali\output_asa.txt’ -append
Write-output “Description NOC-2682-Created by FAli(Nettitude) on 18/12/2021” | Tee-Object -FilePath ‘C:\Users\fali\output_asa.txt’ -append
Write-output “host $ip” | Tee-Object -FilePath ‘C:\Users\fali\output_asa.txt’ -append
Write-output “object-group network Log4j_BadIP_Grp” | Tee-Object -FilePath ‘C:\Users\fali\output_asa.txt’ -append
Write-output “Description NOC-2682-Created by FAli(Nettitude) on 18/12/2021” | Tee-Object -FilePath ‘C:\Users\fali\output_asa.txt’ -append
Write-output “network-object object Log4j_BadIP_$ip” | Tee-Object -FilePath ‘C:\Users\fali\output_asa.txt’ -append
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s