Solved

Exchange Public Folder Reports

Posted on 2016-10-11
11
87 Views
Last Modified: 2016-10-12
Hey Folks,

Im trying to produce a readable report out of Exchange 2007 to determine whether a public folder is mail enabled and or corrupted with illegal characters.

Im currently running the following exports;

ldifde -l publicfolder -f emaillist.txt -r "(proxyAddresses=smtp:*)"

Open in new window


As well as

Start-Transcript -Path "C:\users\account\downloads\exchdump\publicfolder.txt" -NoClobber
Get-PublicFolder -identity "\" -recurse -ResultSize Unlimited
Stop-Transcript

Open in new window



That gives me a good list of the public folders, but I am wondering if there is a better way to export only the ones with illegal characters either in their alias or smtp address?

Any help would be appreciated!
0
Comment
Question by:Aaron Olsen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
11 Comments
 
LVL 16

Expert Comment

by:Todd Nelson
ID: 41839281
You will run the following commands from the Exchange 2007 Management Shell.

This command will return a list of public folders with invalid characters, if any exist.

Get-PublicFolder -Recurse -ResultSize Unlimited | findstr "Warning"

Open in new window


If you want the text output to a file run this command...

Get-PublicFolder -Recurse -ResultSize Unlimited | findstr "Warning" | Out-File "C:\PFInvalidAliases.txt

Open in new window



This command will check all public folders if they are mail-enabled and if the PF is mail-enabled will output the name of the folder and the assigned email address.

Get-PublicFolder -Recurse -ResultSize Unlimited | Where-Object { $_.MailEnabled -eq "True" } | Get-MailPublicFolder | Select-Object Name,PrimarySmtpAddress | Export-Csv "C:\PFEmailList.csv" -NoTypeInformation

Open in new window


Or you can run this simpler command because it only runs against mail-enabled PFs...

Get-MailPublicFolder | Select-Object Name,PrimarySmtpAddress | Export-Csv "C:\PFEmailList.csv" -NoTypeInformation

Open in new window



Let me know.
1
 

Author Comment

by:Aaron Olsen
ID: 41839311
This is what i am doing thus far;

Start-Transcript -Path "C:\users\userid\downloads\exchdump\public\pubd_mailenabledmaildump.txt" -NoClobber
Import-Csv C:\Users\userid\Downloads\exchdump\public\publicdefender.csv | ForEach-Object{
	$server = $_.server
 	$identity = $_.identity
 Get-MailPublicFolder -server $server -identity "$identity" | format-list Name,Alias,PrimarySMTPAddress
}
Stop-Transcript

Open in new window


It returns something along the lines of this;

**********************
Windows PowerShell Transcript Start
Start time: 20161011163601
Username  : ROOT\userid 
Machine	  : SERVERNAME (Microsoft Windows NT 6.1.7601 Service Pack 1) 
**********************
Transcript started, output file is C:\users\userid\downloads\exchdump\public\pubd_mailenabledmaildump.txt


Name               : Process Servers
Alias              : Process_Servers
PrimarySmtpAddress : Process_Servers@masked_email.gov



Get-MailPublicFolder : The public folder '\DEPARTMENTAL DISCUSSIONs\Administration\OPDS\FAX\Process Servers\Completed' is not mail-enabled.
At C:\Users\userid\Downloads\exchdump\public\pubd_mailenabledmaildump.ps1:5 char:22
+  Get-MailPublicFolder <<<<  -server $server -identity "$identity" | format-list Name,Alias,PrimarySMTPAddress
    + CategoryInfo          : InvalidData: (:) [Get-MailPublicFolder], ManagementObjectNotFoundException
    + FullyQualifiedErrorId : D9481B9B,Microsoft.Exchange.Management.MapiTasks.GetMailPublicFolder

Open in new window


It would be nice to perform an if-then-else and spit out the name/alias if its not mail enabled and if it is mail enabled spit out name/alias/primarysmtp/secondarysmtp

Is that possible?
0
 

Author Comment

by:Aaron Olsen
ID: 41839331
Also tried this which is displaying everything but the ProxyAddresses

 Get-MailPublicFolder -server $server -identity "$identity" -properties * | select Name,Alias,PrimarySMTPAddress,@{n="ProxyAddresses";e={$_.ProxyAddresses -join ";"}} | format-list

Open in new window

0
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
LVL 16

Expert Comment

by:Todd Nelson
ID: 41839332
ProxyAddresses isn't a parameter for Get-MailPublicFolder.  But EmailAddresses is and shows all assigned email addresses.
0
 

Author Comment

by:Aaron Olsen
ID: 41839338
Hey Todd,

Thank you, I am now getting the primary smtp address and the email addresses. Here is my problem.

We have public folders with illegal characters. Some are in the alias name, some may be in the smtp address. For those in the SMTP, we set a new primary smtp using a combination of the guid and the email address. which gives us a 32 digit #@domain.gov

Those show up in the proxyAddress attribute. Is there any way to get it to grab that even though its not an attribute field of Get-MailPublicFolder?

This is my code thus far;

Start-Transcript -Path "C:\users\ict_olsen\downloads\exchdump\publicdefender\pubd_mailenabledmaildump.txt" -NoClobber
Import-Csv C:\Users\ict_olsen\Downloads\exchdump\publicdefender\publicdefender.csv | ForEach-Object{
	$server = $_.server
 	$identity = $_.identity
 Get-MailPublicFolder -server $server -identity "$identity" | select Name,Alias,PrimarySMTPAddress,EmailAddresses | format-list 
}
Stop-Transcript

Open in new window


Also, it errors out on folders that are not mail enabled. Is there a way to get it to do action A if it is, and if its not do action B, still giving me the alias name and name?
0
 
LVL 16

Expert Comment

by:Todd Nelson
ID: 41839442
Maybe I am not understanding completely what you are asking or attempting to accomplish, but this is how I am interpreting it.

A PF does not have an alias if it is not mail-enabled.  What are you trying to do with those that are not mail-enabled?

The proxyAddresses attribute in AD is represented by the EmailAddresses parameter with the Get-MailPublicFolder command in Exchange 2007.  There is no other parameter for Get-MailPublicFolder that shows all of the addresses assigned to a mail-enabled PF.

Get-MailPublicFolder is a command only for mail-enabled PFs.  So if your CSV file has PF names in it that are not mail-enabled you might need to modify the command that provided you with the list of mail-enabled PFs.

If you are needing to export a list of PFs that show if they are both mail-enabled or not, run this command...

Get-PublicFolder -Recurse -ResultSize Unlimited | Select Name,MailEnabled | Export-Csv "C:\PFs.csv" -NoTypeInformation

Open in new window


What are you trying to do if the PF is mail-enabled?

What are you trying to do if the PF is not mail-enabled?
0
 

Author Comment

by:Aaron Olsen
ID: 41839478
Hey Todd,

I just need to write an if then else statement to check on whether or not its mail enabled. If it is mail enabled, it needs to run the script i pasted above. If its not, i simply need to know whether or not it has illegal characters in its name.
0
 
LVL 16

Accepted Solution

by:
Todd Nelson earned 500 total points
ID: 41840653
Here is a script I just tested that exports a list of all PFs to a CSV. Then reads the input CSV file to check the value for 'MailEnabled'.  If the value is true, the mail-enabled PF info is exported to a specified CSV file. If the value for 'MailEnabled' is false, the PF info is exported to a different CSV file.

Is that what you are looking for?

Get-PublicFolder -Recurse -ResultSize Unlimited | Select Name,Identity,MailEnabled | Export-Csv "C:\PFs-All.csv" -NoTypeInformation
Import-Csv "C:\PFs.csv" | ForEach-Object {
     if ( $_.MailEnabled -eq "True" ) {
          
          Get-MailPublicFolder -Identity $_.Name | Select-Object Name,Identity,Alias,PrimarySmtpAddress,@{Name='EmailAddresses'; Expression={$_.EmailAddresses -Join ","}} | ft -auto | Out-File "C:\PF-MailEnabled.txt" -Append
     }
     else {
          
          Get-PublicFolder -Identity $_.Identity | Select-Object Name,Identity,MailEnabled | ft -auto | Out-File "C:\PF-NotMailEnabled.txt" -Append
     }
}

Open in new window


Or... If you chose not to use an input file, you can try this script...

$PublicFolders = Get-PublicFolder -Recurse -ResultSize Unlimited
$PublicFolders | ForEach-Object {
     if ( $_.MailEnabled -eq "True" ) {
          Get-MailPublicFolder -Identity $_.Name | Select-Object Name,Identity,Alias,PrimarySmtpAddress,@{Name='EmailAddresses'; Expression={$_.EmailAddresses -Join ","}} | ft -auto | Out-File "C:\PF-MailEnabled.txt" -Append
     }
     else {
          Get-PublicFolder -Identity $_.Identity | Select-Object Name,Identity,MailEnabled | ft -auto | Out-File "C:\PF-NotMailEnabled.txt" -Append
     }
}

Open in new window


Unfortunately, if we use Export-Csv with this script we cannot use the "append" option since it is only available in PowerShell 3.0. However, PS 3.0 is not supported on Exchange 2007; and only using Export-Csv will overwrite the data that was previously written to the files as it iterates through the array.

Therefore, we need to use Out-File because it has an "append" option.  Not ideal but it works.  Unfortunately, using Out-File only writes data to the file dictated by the Screen Buffer and Windows Size settings of the Exchange 2007 Management Shell window.  So make sure to adjust those settings, for both defaults and properties, to allow the full width of the info to be written to the file without "...".

Hope that helps guide you in what you need to accomplish.
0
 

Author Comment

by:Aaron Olsen
ID: 41840714
Will give this a try and report back as soon as i can
0
 

Author Closing Comment

by:Aaron Olsen
ID: 41841131
I had to modify this slightly but it was able to produce what was needed at a finer detail
0
 
LVL 16

Expert Comment

by:Todd Nelson
ID: 41841136
Will you share your final script--but take out any specific identifiers?
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In previous parts of this Nano Server deployment series, we learned how to create, deploy and configure Nano Server as a Hyper-V host. In this part, we will look for a clustering option. We will create a Hyper-V cluster of 3 Nano Server host nodes w…
Check out this step-by-step guide for using the newly updated Experts Exchange mobile app—released on May 30.
In this video we show how to create a Contact in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Recipients >> Contact ta…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Suggested Courses

635 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question