Powershell to export Public Folder Proxyaddresses from Exchange 2003

Hi Guys.

I'm trying to export a list of all SMTP's assigned to my Ex2003 mail enabled Public Folders using the Get-QADObject cmdlet against the 'microsoft exchange system objects' container, but I am having a few problems.

I am using the code below, but when I run it, all I get is "System.Object[]"" as the output next to the Folder name.

I've tried using the '-width' setting, and this does work (ish), but the problem is that some of my PF's have 100 Fax addresses and only one smtp, and even at a very wide width (which leads to a huge output file) I am not 100% sure it is exporting every smtp, and anyway, I only want the SMTP's, not the Fax addresses.

I planned to use this export and manipulate in Excel, but what I would ideally like, is a list of folders, and their SMTPs only next to them, and if I can do that directly from within PS, then great, ie -

folder1, smtp1, smtp2
folder2, smtp1, smtp2, smtp3
folder3, smtp1, smtp2
etc.

I am sure I doing something daft, or doing it cmpletely the wrong way, but help would be appreciated!

Thanks,
Dave.


Get-QADObject -SearchRoot 'my.domain.com/microsoft exchange system objects' -IncludedProperties proxyaddresses | select name,proxyaddresses | Out-File c:\pfsmtpexport.txt

Open in new window

undercover69Asked:
Who is Participating?
 
Chris DentPowerShell DeveloperCommented:
Hi Dave,

Yes, certainly, this should do it if you'd care to give it a shot.

Chris
Get-QADObject `
    -SearchRoot 'my.domain.com/microsoft exchange system objects' `
    -IncludedProperties proxyAddresses | `
  Select-Object Name, @{n='proxyAddresses';e={"$($_.proxyAddresses | ?{ $_ -Like 'smtp*' })"}} | `
  Out-File c:\pfsmtpexport.txt

Open in new window

0
 
Chris DentPowerShell DeveloperCommented:
Hi Dave,

This is caused by proxyAddresses, it is an array (signified by []) not a single value. When you use it like this you get an implicit "ToString()" call on the value, in this case that gives you System.Object[] rather than the actual values.

If you make PowerShell join the array into a string it should be a lot happier. In this case we can do that by enclosing the original value in quotes and selecting it as a custom property.

Chris
Get-QADObject `
    -SearchRoot 'my.domain.com/microsoft exchange system objects' `
    -IncludedProperties proxyAddresses | `
  Select-Object Name, @{n='proxyAddresses';e={"$($_.proxyAddresses)"}} | `
  Out-File c:\pfsmtpexport.txt

Open in new window

0
 
undercover69Author Commented:
Hi Chris,

Thanks again for the expert help!

One thing though, I am still getting all the data from the proxyaddresses field (ie including the Fax addresses), whereas I only really want the SMTP addresses.
I can export from here out to excel and then mess about with it there, but for training purposes (:-)) can can it be filtered from PS?

Thanks again,
Dave
0
 
undercover69Author Commented:
Great stuff Chris, thanks again mate :-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.