Simple AD Powershell Command to grab SIP

This topic contains 8 replies, has 3 voices, and was last updated by Profile photo of Steve Steve 1 month, 1 week ago.

  • Author
    Posts
  • #56047
    Profile photo of Steve
    Steve
    Participant

    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
    Profile photo of Gary
    Gary
    Participant

    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
    Profile photo of Dan Potter
    Dan Potter
    Participant

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

  • #56107
    Profile photo of Steve
    Steve
    Participant

    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
    Profile photo of Dan Potter
    Dan Potter
    Participant

    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
    Profile photo of Steve
    Steve
    Participant

    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
    Profile photo of Dan Potter
    Dan Potter
    Participant
    
    get-aduser -filter "anr -eq 'sip:'" -Properties msRTCSIP-PrimaryUserAddress,proxyaddresses | select samaccountname,msRTCSIP-PrimaryUserAddress,@{n='smtp';e={$_.proxyaddresses | ? {$_ -Cmatch 'SMTP'}}} |select -First 10
    
    
  • #56114
    Profile photo of Dan Potter
    Dan Potter
    Participant

    add in userprincipalname to the select

  • #56125
    Profile photo of Steve
    Steve
    Participant

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

You must be logged in to reply to this topic.