Powershell to list Mobile & TelephoneNumber

taartero
taartero used Ask the Experts™
on
I am looking for a PowerShell script to list users Mobile (number) and TelephoneNumber's.

I am looking for native PowerShell commands, not 3rd party.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
You can use ADSI. This is pretty nice explained (with examles) at http://powershell.com/cs/blogs/ebook/archive/2009/04/10/chapter-19-user-management.aspx
In my everyday tasks I'm using 3rd party free addon from Quest. In 2008 R2 you have also built-in AD cmdlets.

Author

Commented:
I am on 2008 R2, but I am not seeing the info in either:
Get-Mailbox -identity "JohnDoe" | fl
get-aduser -filter {samaccountname -like "JohnDow"}| fl
I would give this a shot

get-aduser -identity {username} | select-object phonenumber, mobile
Rowby Goren Makes an Impact on Screen and Online

Learn about longtime user Rowby Goren and his great contributions to the site. We explore his method for posing questions that are likely to yield a solution, and take a look at how his career transformed from a Hollywood writer to a website entrepreneur.

Commented:
Try this

get-aduser USERNAME -properties MobilePhone, Officephone | Select MobilePhone, Officephone

Author

Commented:
if you use get-aduser the     -identity     doesn't work the same way as exchange. This is why my example above is written that way.

When you pipe to FL I was under the impression that all properties listed are the only ones available.

Mobile and PhoneNumber are not options for   get-aduser
You can always use the -includeallproperties switch. This will return more than the default as to what is listed.

Author

Commented:
I just tried the get-aduser USERNAME

that does allow me not to use the syntax I used above:
-filter {samaccountname -like "JohnDow"}

but  those fields don't seem to work:
MobilePhone, Officephone | Select MobilePhone, Officephone

Author

Commented:
interesting, what is the -includeallproperties
Sorry disregard mine. I am confusing get-qaduser switches with get-aduser.
Commented:
To make sure you are getting the correct attributes try this

get-aduser USERNAME -properties * | Select *

This will list out all attributes for the user.

Commented:
Are you asking about Exchange addons? Or native powershell as you wrote in your question?
Neil RussellTechnical Development Lead

Commented:
"I am looking for native PowerShell commands, not 3rd party"

There are NO NATIVE powershell commands for this strictly speaking. The get-ad* commandlets are added to powershell in a domain environment, they are not NATIVE powershell commands.

Far too often we see people who have this adverse reaction to using perfectly good, free, tested and proven commandlets that make a sys admins life so much easier, without any justification.

The quest commandlets make life so much easier. Why are you so against there use? Why use 3 lines to do what 1 can do?

Author

Commented:
Thanks,

This got me the cell numbers with the property MOBILE:

get-aduser USERNAME -properties * | Select MOBILE

get-aduser USERNAME -properties * | Select TELEPHONENUMBER

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial