Link to home
Start Free TrialLog in
Avatar of Aaron Olsen
Aaron OlsenFlag for United States of America

asked on

Exchange Public Folder Reports

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!
Avatar of Todd Nelson
Todd Nelson
Flag of United States of America image

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.
Avatar of Aaron Olsen

ASKER

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?
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

ProxyAddresses isn't a parameter for Get-MailPublicFolder.  But EmailAddresses is and shows all assigned email addresses.
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?
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?
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.
ASKER CERTIFIED SOLUTION
Avatar of Todd Nelson
Todd Nelson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Will give this a try and report back as soon as i can
I had to modify this slightly but it was able to produce what was needed at a finer detail
Will you share your final script--but take out any specific identifiers?