none
retrieve sip address for all users remote 'Sip' from begining of string RRS feed

  • Question

  • I am trying to remove the 'SIP' prefix when returning the sip address for users on my domain but i am not sure do remove it after retrieveing the list of users. The address returns blank when i run my script with the -replace request. it works fine without it but has the SIP: at the beggining of the string for the address. Any ideas what i am doing wrong?

    Get-Mailbox -ResultSize Unlimited  -OrganizationalUnit $_ |Select-Object DisplayName,Samaccountname,UPN,@{Name=“EmailAddresses”;Expression={$_.EmailAddresses |Where-Object {$_.PrefixString -eq “sip”} |% { $_.prefixstring -replace "sip:",""}}}}

    Monday, April 18, 2016 1:12 PM

Answers

  • If you wouldn't insist on jamming everything on one line then you would more easily see how to solve the problem:

    Get-Mailbox -ResultSize Unlimited -OrganizationalUnit $_ | 
    Select-Object DisplayName, 
    	Samaccountname, 
    	UPN, 
            @{n='EmailAddresses';e={$_.EmailAddresses | ?{$_ -match '^sip'}|%{$_ -replace 'sip:',''}}}


    \_(ツ)_/



    • Edited by jrv Monday, April 18, 2016 2:57 PM
    • Marked as answer by glacket Monday, April 18, 2016 3:19 PM
    Monday, April 18, 2016 2:32 PM

All replies

  • Get-Mailbox -ResultSize Unlimited  -OrganizationalUnit $_ |Select-Object DisplayName,Samaccountname,UPN,@{Name=“EmailAddresses”;Expression={($_.EmailAddresses |Where-Object {$_.PrefixString -eq “sip”}).replace("sip:","")}}

    Use of $_.prefixstring at the end  could be the issue in your example. I have not tested mine as i do not have exchange . Please let me know if it works.
    Monday, April 18, 2016 1:39 PM
  • Thanks, but that does not work. I am not sure what other property i could search by instead of prefixstring, to retrieve just the sip address due to it being part of the proxy address which has multiple addresses.
    Monday, April 18, 2016 1:53 PM
  • Can you post 1 output without the replace  ? 

    The idea is to see that expression contains string value. 

    Monday, April 18, 2016 2:07 PM
  • Get-Mailbox -ResultSize Unlimited  -OrganizationalUnit $_ |Select-Object DisplayName,Samaccountname,UPN,@{Name=“EmailAddresses”;Expression={$_.EmailAddresses |Where-Object {$_.PrefixString -eq “sip”}}}}

    this returns, displayname, samaccountname, and sip address with the SIP: string at the beginning. The property of the address is "proxyaddressString" which contains "SIP:useremail@domain.com"
    Monday, April 18, 2016 2:25 PM
  • If you wouldn't insist on jamming everything on one line then you would more easily see how to solve the problem:

    Get-Mailbox -ResultSize Unlimited -OrganizationalUnit $_ | 
    Select-Object DisplayName, 
    	Samaccountname, 
    	UPN, 
            @{n='EmailAddresses';e={$_.EmailAddresses | ?{$_ -match '^sip'}|%{$_ -replace 'sip:',''}}}


    \_(ツ)_/



    • Edited by jrv Monday, April 18, 2016 2:57 PM
    • Marked as answer by glacket Monday, April 18, 2016 3:19 PM
    Monday, April 18, 2016 2:32 PM
  • You can select "proxyaddressString" property and use replace on that.
    Monday, April 18, 2016 2:32 PM
  • You can select "proxyaddressString" property and use replace on that.

    There is no such thing on a mailbox.  That is for AD only.

    \_(ツ)_/

    Monday, April 18, 2016 3:08 PM
  • You are correct, your syntax is easier to see. The only part i dont understand is below.
    ?{$_ -match '^sip'}
    How is that retrieving only the sip proxy address using ^sip? Why doesnt *sip work?
    Monday, April 18, 2016 3:10 PM
  • You are correct, your syntax is easier to see. The only part i dont understand is below.
    ?{$_ -match '^sip'}
    How is that retrieving only the sip proxy address using ^sip? Why doesnt *sip work?

    match uses RegEx.

    \_(ツ)_/

    Monday, April 18, 2016 3:11 PM
  • Very helpful, i learned something new. Thanks!
    Monday, April 18, 2016 3:20 PM
  • You are welcome.  Learn to format code. t is very helpful.  Also learn the basics of RegEx as it is used everywhere in  PowerShell.

    \_(ツ)_/

    Monday, April 18, 2016 3:29 PM