I am writing this PowerShell script to export some information like:
Name
Mail
ObjectClass
SMTP Address (only SMTP and smtp addresses)
DistinguishedName
RecipientTypeDetails --> This is to know what type of Mailbox (Shared, User,Resource,etc...)
WhenMailboxCreated
WhenChanged
WhenCreated
Identity
SKUAssigned
Because somehow it only shows the: Name, Mail, ObjectClass and DistinguishedName, while the SMTP Address column is blank?
This is the script I've got:
function Get-EmailAddress
{
[CmdletBinding()]
param
(
[Parameter(Mandatory = $True,
ValueFromPipeline = $True,
ValueFromPipelineByPropertyName = $True,
HelpMessage = 'What e-mail address would you like to find?')]
[string[]]$EmailAddress
)
process
{
foreach ($address in $EmailAddress)
{
Get-ADObject -Properties mail, proxyAddresses -Filter "mail -like '*$address*' -or proxyAddresses -like '*$address*'" |
Select Name,
Mail,
ObjectClass,
@{Label='SMTP Address';Expression={ $address.proxyAddresses | ?{ $address -Like "*smtp*" } -replace 'smtp:' -join ';' }},
DistinguishedName
Get-Recipient $address |
Select DisplayName,
RecipientType,
RecipientTypeDetails,
EmailAddresses,
*When*,
Identity,
SKUAssigned
}
}
}
Get-EmailAddress HelpDesk,ServiceDesk | Export-Csv -Path C:\TEMP\Result.csv -NoTypeInformation
I had to go through similar thing.
I'm not sure why, but you have to include "SMTP" Property in your Get-ADObject -Properties SMTP
or just get them all by using -Properties *