Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
New Member

Postini Safelist/Blocklist migration script

Has anyone written a script to take safelist/blocklist entries from Postini and modify them to spit out a CSV file that a Cisco IronPort SMA can understand? If so, would you mind sharing please?

Everyone's tags (4)
1 REPLY
New Member

Postini Safelist/Blocklist migration script

Here's the script we use.  We're in an Exchange 2010 environment, so the script looks up the current aliases for each primary address in the Postini file in our Active Directory.  This way we drop mailboxes that are gone but still had Postini entries and we get any new aliases that hadn't made it into Postini.  the resultant file can be imported into Ironport.

It's been a while so I don't remember if I had to tweak lline endings or anything, but this should get you ont eh right track.

$sess = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://YourServersFQDN/powershell -Authentication kerberos -WarningAction SilentlyContinue

Import-PSSession $sess -WarningAction SilentlyContinue -verbose

    $infile = 'postini.csv'

    $outfile = 'slbl.csv'

    $postini = $null # Input from Postini

    $Iron = $null # Output for Ironport

    $aliases = $null

    $Mailbox = $null

    $datestring = $null

    $holddate = $null

    $blocks = $null

    $blocksenders = $null

    $safe = $null

    $safeSenders = $null

    $innerpostini = $null

    $counter = 0

    # Import input file

    $postini = Import-Csv -Path $InFile | Where-Object {$_.approved_senders -ne 'NULL' -or $_.blocked_senders -ne 'NULL'}

    # Initialiaze output file

    Remove-Item $outfile

    $holddate = Get-Date

    $datestring = ($holddate).toshortdatestring() + ', ' + ($holddate).toshorttimestring()

    # "# File exported by the Powershell at $Datestring" | Out-File -LiteralPath $OutFile

    $postini | % {

        # For each line, Get aliases

        Write-Output "$counter - $($_.address)"

        $innerpostini = $_

        $Mailbox = Get-Mailbox $_.address -ErrorAction 'SilentlyContinue'

        $counter++

        if ($Mailbox -ne $null) {

            $aliases = (Get-Mailbox $_.address | Select-Object emailaddresses -ExpandProperty emailaddresses | where {$_ -like 'smtp*'}).replace('smtp:','').replace('SMTP:','')

            $aliases | % {

                $blocks = $null

                $blocksenders = $null

                $safe = $null

                $safeSenders = $null

            # For each Alias process blocks, Then approved

            if ($innerpostini.blocked_senders -ne 'NULL') {

                $blocksenders = ($innerpostini.blocked_senders).replace(',',', ').replace(' @',' ')

                if ($blocksenders.substring(0,1) -eq '@') {

                    $blocksenders = $blocksenders.remove(0,1)

                }

                $blocks = $_ + ', BLOCKED, ' + $blocksenders

                $blocks | Out-File $OutFile -Append -NoClobber

            }

            if ($innerpostini.approved_senders -ne 'NULL') {

                $safesenders = ($innerpostini.approved_senders).replace(',',', ').replace(' @',' ')

                if ($safesenders.substring(0,1) -eq '@') {

                    $safesenders = $safesenders.remove(0,1)

                }

                $safe = $_ + ', SAFE, ' + $safesenders

                $safe | Out-File $OutFile -Append -NoClobber

            }

        }

    }

}

364
Views
0
Helpful
1
Replies
CreatePlease login to create content