Search users information based on msRTCSIP-Line

I am looking to create a scrip to look up a users information based on the extension listed in the msRTCSIP-Line attribute.

I have the below script but need to incorporate an optional value to allow for the different number ranges:

Get-ADUser -Filter {msRTCSIP-Line -like "tel:$ext"} -Properties Name, Displayname, msRTCSIP-Line, msRTCSIP-UserEnabled | FL Name, Displayname, msRTCSIP-Line, msRTCSIP-UserEnabled

What needs to be added is an IF\Else statement to incorporate the following:

If the extension is greater that 6000 it will need to prefix $ext with +2721404 or +2721406. If the number is less than 6000 then prefix $ext with +2721650.

Hope I have made the requirements clear, assistance will be greatly appriciated.

June 18th, 2015 9:32am

This should  do it.

$fullext=if([int]$ext -gt 6000){ "tel:+2721404$ext")else("tel:+2721406$ext"}

Get-ADUser -Filter "msRTCSIP-Line -eq '$fullExt'" -Properties Name, Displayname, msRTCSIP-Line, msRTCSIP-UserEnabled

Free Windows Admin Tool Kit Click here and download it now
June 18th, 2015 10:37am

Hi James,

Please note to replace "(" with "{" in the script provided by Jrv.

$fullext=if([int]$ext -gt 6000){ "tel:+2721404$ext"}else{"tel:+2721406$ext"}

If there is anything else regarding this issue, please feel free to post back.

Best Regards,

Anna Wang

June 21st, 2015 3:56am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics