Simple AD Powershell Command to grab SIP

Welcome Forums General PowerShell Q&A Simple AD Powershell Command to grab SIP

This topic contains 8 replies, has 3 voices, and was last updated by

 
Participant
2 years, 2 months ago.

  • Author
    Posts
  • #56047

    Participant
    Points: 0
    Rank: Member

    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

  • #56053

    Participant
    Points: 66
    Rank: Member

    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'
    }
    
  • #56054

    Participant
    Points: 21
    Rank: Member

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

  • #56107

    Participant
    Points: 0
    Rank: Member

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

  • #56110

    Participant
    Points: 21
    Rank: Member

    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

  • #56111

    Participant
    Points: 0
    Rank: Member

    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.

  • #56113

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

    Participant
    Points: 21
    Rank: Member

    add in userprincipalname to the select

  • #56125

    Participant
    Points: 0
    Rank: Member

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

The topic ‘Simple AD Powershell Command to grab SIP’ is closed to new replies.