EMS (2007) Script: ConvertTo-HTML = Garbage
I put together some code that grabs any mailbox without an email address policy and then creates an HTML report listing those mailboxes along with their size and SMTP addresses. The problem is that the SMTP addresses shows up as "Microsoft.Exchange.Data.ProxyAddressCollection" instead of the expected addresses. If I throw the data out to a text file instead of converting it to HTML it shows everything correctly. Why does this happen?
I know that using Format-Table along with either ConvertTo-HTML or Export-CSV causes these types of issues, but I'm not doing that. I'm obviously doing something wrong however and have been smacking my head against the wall on this one. Anyone have any idea why the addresses don't show up correctly after being converted to HTML? Here is my code...
Code Snippet
$a = "<style>"
$a = $a + "BODY{background-color:white;}"
$a = $a + "TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}"
$a = $a + "TH{border-width: 1px;padding: 8px;border-style: solid;border-color: black;background-color:white}"
$a = $a + "TD{border-width: 1px;padding: 8px;border-style: solid;border-color: black;background-color:white}"
$a = $a + "</style>"
$mbDataCollection = @()
Get-Mailbox -ResultSize Unlimited | Where { $_.EmailAddressPolicyEnabled -Ne 'True' } |
foreach-object{
$mbStats = get-mailboxstatistics $_.identity
$mbData = "" | Select Name,Alias,DatabaseName,TotalItemSize,EmailAddresses
$mdbArray = $_.Database.ToString().split("\")
$mbData.Name = $_.Name
$mbData.Alias = $_.Alias
$mbData.Databasename = $mdbArray[2]
$mbData.TotalItemSize = $mbStats.TotalItemSize
$mbData.EmailAddresses = $_.EmailAddresses
$mbDataCollection += $mbData
}
$mbDataCollection | Convertto-html -head $a -body "<H2>Mailboxes with no email policy</H2>" | out-file C:\noemailpolicy.html
Invoke-Expression C:\noemailpolicy.html
June 3rd, 2008 3:05am
This forum is for exchange related issues. For questions aboutScript please use the Development Forum which would be the most relevant forum for your question.
Development Forum: http://forums.microsoft.com/TechNet/ShowForum.aspx?ForumID=838&SiteID=17
Free Windows Admin Tool Kit Click here and download it now
June 4th, 2008 5:32am
Thanks for the information. Because of the description of this forum and the fact that my question is about EMS outputI thought it to be relevant. Maybe questions beyond simple EMS cmdlet useage don't belong here.
Admin Topics discussed include: Administration across all server roles, management, Exchange Management Console (EMC) , Exchange Management Shell, storage and performance
June 7th, 2008 12:44am