techdrive
asked on
powershell match get mailbox
I have been tasked with trying to locate all the alias and verify that the smtp address matches with each account. The issue is I am doing this by hand and with many accounts it will take a while.
what powershell command will allow me to match the aliasname with the primarysmtpaddress
I am stuck and cannot get beyond this point.
get-mailbox -resultsize:unlimited
what powershell command will allow me to match the aliasname with the primarysmtpaddress
I am stuck and cannot get beyond this point.
get-mailbox -resultsize:unlimited
Use the below command below...
On Screen
To CSV FIle
On Screen
$Users = get-content "c:\users.txt"
Foreach ($User in $Users) {
Get-Mailbox -Identity $User | select DisplayName, PrimarySMTPAddress
}
To CSV FIle
$Users = get-content "c:\users.txt"
Foreach ($User in $Users) {
Get-Mailbox -Identity $User | select DisplayName, PrimarySMTPAddress | out-file "c:\userSMTPAddresses.csv" -append
}
ASKER
thanks will but may I also add. Looking for something that would automate this instead of eye balling. I guess I would have to remove the domain @company.com because the alias is suppose to match the primarysmtpaddress and if it does not I would like a report.
You can use any of the following methods to look up a mailbox using the Identity parameter.
-Identity <MailboxIdParameter>
The Identity parameter identifies the mailbox. You can use one of the following values:
* GUID
* Distinguished name (DN)
* Domain\Account
* User principal name (UPN)
* LegacyExchangeDN
* SmtpAddress
* Alias
Required? false
Position? 1
Default value
Accept pipeline input? True
Accept wildcard characters? true
Will.
-Identity <MailboxIdParameter>
The Identity parameter identifies the mailbox. You can use one of the following values:
* GUID
* Distinguished name (DN)
* Domain\Account
* User principal name (UPN)
* LegacyExchangeDN
* SmtpAddress
* Alias
Required? false
Position? 1
Default value
Accept pipeline input? True
Accept wildcard characters? true
Will.
ASKER
Let me clarify I might not be coming across clearly.Iruiz52 is somewhat close to what I am asking.
This below is a good idea but will not work
Get-mailbox | select name, ($_.alias -match $_.primarysmtpaddress)
1) I wanted something that while its processing this would at least when doing the comparison would filter out the domain name@company.com and then that way would be able to compare the alias in which we have firstname.lastname to the primarysmtpaddress firstname.lastname@company .com which would by powershell do the comparison for me.
So here is my data in theory in exchange and how it sees this.
alias primarysmtpaddress
firstname.lastname firstname.lastname@somecom pany.com
dollar.bill dollar.bill@somecompany.co m
jane.doe jane.doe@somecompany.com
Step 1 would like for the somecompany.com to be removed so that it can filter it properly. NOT in the exchange environment but some substring for processing.
alias primarysmtpaddress
firstname.lastname firstname.lastname
dollar.bill dollar.bill
jane.doe jane.doe
Now its the same now and powershell can compare the alias vs the primarysmtpaddress and anything that does not matches comes back and reports.
This below is a good idea but will not work
Get-mailbox | select name, ($_.alias -match $_.primarysmtpaddress)
1) I wanted something that while its processing this would at least when doing the comparison would filter out the domain name@company.com and then that way would be able to compare the alias in which we have firstname.lastname to the primarysmtpaddress firstname.lastname@company
So here is my data in theory in exchange and how it sees this.
alias primarysmtpaddress
firstname.lastname firstname.lastname@somecom
dollar.bill dollar.bill@somecompany.co
jane.doe jane.doe@somecompany.com
Step 1 would like for the somecompany.com to be removed so that it can filter it properly. NOT in the exchange environment but some substring for processing.
alias primarysmtpaddress
firstname.lastname firstname.lastname
dollar.bill dollar.bill
jane.doe jane.doe
Now its the same now and powershell can compare the alias vs the primarysmtpaddress and anything that does not matches comes back and reports.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks i was actually thinking of settling for excel. It seems to be the best way to do this.
Yeah why over complicate things if you are already exporting it to a csv.
Will.
Will.
Get-Mailbox -resultsize unlimited | Select Name, Alias, PrimarySMTPAddress, @{Name='EmailAddresses';Ex