Simple AD Powershell Command to grab SIP


I haven’t touched Powershell in about 6 months and am stumped on a very easy question. I have a list of email address and I am trying to pull the AD accounts along with SAM names and SIP address from AD.

This is what I have so far, and I am able to pull single address at a time using -Filter and {mail -eq “”} but I have close to 20,000 users to pull.


I need to make this line of code work with a variable that is a list of email address:

get-aduser -Filter {mail -eq ‘’} -Properties Enabled, Name, SamAccountName, EmailAddress,‘msRTCSIP-PrimaryUserAddress’ | Export-csv c:\temp\new1.csv

Untested, but try this.

$emails = Import-Csv C:\temp\sip.csv
Foreach ($email in $emails) {
Get-ADUser -Filter {mail -eq $email} -Properties Enabled,Name,SamAccountName,EmailAddress,'msRTCSIP-PrimaryUserAddress'

-filter {anr -eq ‘’}

Didn’t have success with either, Dan’s line works same the original line I had, but only for one user at a time.

If you want all users who have a sip address you could do something like below and compare your email list to the results. Assuming you have really strict policies and the mail attribute corresponds to the primarysmtp.

get-aduser -filter “anr -eq ‘sip:’” -Properties msRTCSIP-PrimaryUserAddress,mail

Thanks Dan, I will attempt, all users on this list do have a sip Address, I just need to make sure their sip address match their UPN, SipProxy and email as well.

get-aduser -filter "anr -eq 'sip:'" -Properties msRTCSIP-PrimaryUserAddress,proxyaddresses | select samaccountname,msRTCSIP-PrimaryUserAddress,@{n='smtp';e={$_.proxyaddresses | ? {$_ -Cmatch 'SMTP'}}} |select -First 10

add in userprincipalname to the select

Thanks I was able to pull all the users and it worked.