Exchange Need Public Folder Path and Email Addresses

This topic contains 1 reply, has 2 voices, and was last updated by Profile photo of Rob Simmers Rob Simmers 3 months, 2 weeks ago.

  • Author
    Posts
  • #50830
    Profile photo of Chris Ediger
    Chris Ediger
    Participant

    I need to generate a report that lists all the Mail Enabled public folders with their associated path (i.e. \IT\OPKBranch\ServiceDesk) and all email addresses associated with that folder. This is what I have and it just gives me a jumbled mess.

    $mailenabled = get-publicfolder -Recurse -Resultsize unlimited | select Identity,MailEnabled | where {$_.mailenabled -eq $true}
    $emailaddresses = $mailenabled.identity | get-mailpublicfolder | select emailaddresses

    $props = @{
    'Public Folder Path' = $mailenabled.identity;
    'EmailAddresses' = $emailaddresses.emailaddresses
    }

    $objs = New-Object -TypeName PSObject -Property $props
    $objs | format-table -wrap

    I'm kind of a self taught noob to PowerShell.

  • #50847
    Profile photo of Rob Simmers
    Rob Simmers
    Participant

    If the email addresses are an array of addresses, I'd recommend making the object look something like this:

    Name                      Alias       EmailAddress     
    ----                      -----       ------------     
    \IT\OPKBranch\ServiceDesk ServiceDesk joe@company.com  
    \IT\OPKBranch\ServiceDesk ServiceDesk sally@company.com
    \IT\OPKBranch\ServiceDesk ServiceDesk rob@company.com  
    \IT\OPKBranch\Operations  Operations  frank@company.com
    \IT\OPKBranch\Operations  Operations  joe@company.com  
    \IT\OPKBranch\Operations  Operations  tammy@company.com
    

    This gives you flexibility to use Powershell to do some basic reporting, like how many users are in each folder:

    PS C:\Users\Rob> $test | Group-Object -Property Alias -NoElement
    
    Count Name                     
    ----- ----                     
        3 ServiceDesk              
        3 Operations   
    

    or if you simply want to get the email addresses:

    PS C:\Users\Rob> $test | Where {$_.Alias -eq 'Operations'} | Select -ExpandProperty EmailAddress
    frank@company.com
    joe@company.com
    tammy@company.com
    

    Assuming that EmailAddresses is returned as an array, you could try an approach like this:

    $mailEnabledFolders = Get-PublicFolder -Recurse -Resultsize unlimited | Where {$_.mailenabled -eq $true}
    
    $results = foreach ($folder in $mailEnabledFolders) {
        
        $mailPublicFolder = Get-MailPublicFolder -Identity $folder.Identity
        foreach ($emailAddress in $mailPublicFolder.EmailAddresses) {
            $mailPublicFolder | Select Name, Alias, @{Name="EmailAddress";Expression={$emailAddress}}
        }
    }
    
    $results
    

You must be logged in to reply to this topic.