# Simple AD Powershell Command to grab SIP

**URL:** <https://forums.powershell.org/t/simple-ad-powershell-command-to-grab-sip/7408>\
**Category:** PowerShell Help\
**Created:** [October 25, 2016, 3:39pm UTC](https://forums.powershell.org/t/simple-ad-powershell-command-to-grab-sip/7408 "2016-10-25T15:39:25Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![creedprljm](https://avatars.discourse-cdn.com/v4/letter/c/a3d4f5/32.png) [@creedprljm](https://forums.powershell.org/u/creedprljm)\
**Post date:** [October 25, 2016, 3:39pm UTC](https://forums.powershell.org/t/simple-ad-powershell-command-to-grab-sip/7408/1 "2016-10-25T15:39:25Z")

</div>

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.

> <https://gist.github.com/anonymous/5423c265c9fdac7303ad06257adf0cca>

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](http://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

---

<div class="post-metadata">

**Author:** ![gazza](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/gazza/32/130_2.png) [@gazza](https://forums.powershell.org/u/gazza)\
**Post date:** [October 25, 2016, 5:01pm UTC](https://forums.powershell.org/t/simple-ad-powershell-command-to-grab-sip/7408/2 "2016-10-25T17:01:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dan-potter](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/dan-potter/32/138_2.png) [@dan-potter](https://forums.powershell.org/u/dan-potter)\
**Post date:** [October 25, 2016, 6:02pm UTC](https://forums.powershell.org/t/simple-ad-powershell-command-to-grab-sip/7408/3 "2016-10-25T18:02:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![creedprljm](https://avatars.discourse-cdn.com/v4/letter/c/a3d4f5/32.png) [@creedprljm](https://forums.powershell.org/u/creedprljm)\
**Post date:** [October 26, 2016, 12:12pm UTC](https://forums.powershell.org/t/simple-ad-powershell-command-to-grab-sip/7408/4 "2016-10-26T12:12:31Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dan-potter](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/dan-potter/32/138_2.png) [@dan-potter](https://forums.powershell.org/u/dan-potter)\
**Post date:** [October 26, 2016, 12:56pm UTC](https://forums.powershell.org/t/simple-ad-powershell-command-to-grab-sip/7408/5 "2016-10-26T12:56:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![creedprljm](https://avatars.discourse-cdn.com/v4/letter/c/a3d4f5/32.png) [@creedprljm](https://forums.powershell.org/u/creedprljm)\
**Post date:** [October 26, 2016, 1:00pm UTC](https://forums.powershell.org/t/simple-ad-powershell-command-to-grab-sip/7408/6 "2016-10-26T13:00:44Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dan-potter](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/dan-potter/32/138_2.png) [@dan-potter](https://forums.powershell.org/u/dan-potter)\
**Post date:** [October 26, 2016, 1:05pm UTC](https://forums.powershell.org/t/simple-ad-powershell-command-to-grab-sip/7408/7 "2016-10-26T13:05:31Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dan-potter](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/dan-potter/32/138_2.png) [@dan-potter](https://forums.powershell.org/u/dan-potter)\
**Post date:** [October 26, 2016, 1:06pm UTC](https://forums.powershell.org/t/simple-ad-powershell-command-to-grab-sip/7408/8 "2016-10-26T13:06:13Z")

</div>

add in userprincipalname to the select

---

<div class="post-metadata">

**Author:** ![creedprljm](https://avatars.discourse-cdn.com/v4/letter/c/a3d4f5/32.png) [@creedprljm](https://forums.powershell.org/u/creedprljm)\
**Post date:** [October 26, 2016, 2:51pm UTC](https://forums.powershell.org/t/simple-ad-powershell-command-to-grab-sip/7408/9 "2016-10-26T14:51:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:40pm UTC](https://forums.powershell.org/t/simple-ad-powershell-command-to-grab-sip/7408/10 "2024-05-16T20:40:08Z")

</div>


