Author Posts

October 25, 2016 at 9:09 pm

Hi

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 "youremail.com"} but I have close to 20,000 users to pull.

TLDR;

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

get-aduser -Filter {mail -eq 'youremail@domain.com'} -Properties Enabled, Name, SamAccountName, EmailAddress,'msRTCSIP-PrimaryUserAddress' | Export-csv c:\temp\new1.csv

October 25, 2016 at 10:31 pm

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'
}

October 25, 2016 at 11:32 pm

-filter {anr -eq 'sip:someone@somewhere.com'}

October 26, 2016 at 5:42 pm

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

October 26, 2016 at 6:26 pm

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

October 26, 2016 at 6:30 pm

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.

October 26, 2016 at 6:35 pm


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

October 26, 2016 at 6:36 pm

add in userprincipalname to the select

October 26, 2016 at 8:21 pm

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