1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
$Mailbox = @{ ResultSize = “Unlimited” } $Filter = @{ FilterScript = {$_.PrefixString -ceq “smtp”} } $Select = @{ Property = @{Name=”First Name”;Expression={$_.DisplayName.Split(“,”)[1].Trim()}}, @{Name=”Last Name”;Expression={$_.DisplayName.Split(“,”)[0].Trim()}}, “DisplayName”, “ServerName”, “PrimarySmtpAddress”, @{Name=”EmailAddresses”;Expression={$_.EmailAddresses | Where-Object @Filter}} } Get-Mailbox @Mailbox | Select-Object @Select #Split all SMTP using comma (Get-Mailbox -ResultSize Unlimited |Select-Object DisplayName,ServerName,PrimarySmtpAddress, @{Name=“EmailAddresses”;Expression={$_.EmailAddresses |Where-Object {$_.PrefixString -ceq “smtp”} | ForEach-Object {$_.SmtpAddress}}}) |Select-Object DisplayName,ServerName,PrimarySmtpAddress, @{Name=“EmailAddresses”;Expression={$_.EmailAddresses.Split() -join(“,”)}} |Export-Csv C:\scripts\temp\addresses2.csv -NoTypeInformation Get-Mailbox -ResultSize Unlimited |Select Name, PrimarySMTPAddress, @{Name=’EmailAddresses’;Expression={[string]::join(“;”, ($_.EmailAddresses -cmatch ‘smtp’))}} Get-Mailbox -ResultSize Unlimited | Select-Object DisplayName,PrimarySmtpAddress, @{Name=“EmailAddresses”;Expression={$_.EmailAddresses | Where-Object {$_.PrefixString -ceq “smtp”} | ForEach-Object {$_.SmtpAddress}}} | Sort-Object DisplayName | Export-CSV “\\sf3\user1\shared\share\e\all_SMTP_Addresses.csv” -NoTypeInformation |
testest test