I need some help in combining the two Power-Shell command to generate the CSV result with the column as follows:
Code: Select all
Mailbox Location, Name, PrimarySmtpAddress, OU
OnPremise, OnPremise User1, OnPremise.User1@domain.com, domain.com/Users/Exchange 2013
OnPremise, OnPremise User2, OnPremise.User2@domain.com, domain.com/Users/Exchange 2013
…
Office365, Office365 User1, Office365.User1@domain.com, domain.com/Users/Exchange Online
Office365, Office365 User2, Office365.User2@domain.com, domain.com/Users/Exchange Online
Script to get the On-premise Users based on HomeMDB AD attributes:
Code: Select all
Get-ADUser -ResultSetSize 99999 -Filter * -Properties homeMDB, msExchRemoteRecipientType, msExchRecipientDisplayType, msExchRecipientTypeDetails,
proxyAddresses |
Where-Object { $_.homeMDB -ne $null }
Code: Select all
Get-ADUser -ResultSetSize 99999 -Filter * -Properties homeMDB, msExchRemoteRecipientType, msExchRecipientDisplayType, msExchRecipientTypeDetails,
proxyAddresses |
Where-Object {
(($_.msExchRemoteRecipientType -eq 4) -or ($_.msExchRemoteRecipientType -eq 20) -or ($_.msExchRemoteRecipientType -eq 21) -or ($_.msExchRemoteRecipientType
-eq 100)) -and
#( $_.msExchRecipientDisplayType -eq '-2147483642') -and
(($_.msExchRecipientTypeDetails -eq '2147483648') -or (($_.msExchRecipientTypeDetails -eq '34359738368'))) -and
( $_.proxyAddresses -match "onmicrosoft.com")
}