Solved

Need a script to see all mobile telephone users on domain

Posted on 2011-03-22
3
401 Views
Last Modified: 2012-05-11
Hi Experts

I'm a total noob if it comes to scripting.
I need a list of all the users on the domain that use mobile phones.  Our asset list is far from actual so I wanted to generate this list using a script.

So basically I need a script that check's if the "mobile" field in the Active Directory user properties is filled out on all user accounts in our domain.

Any help is greatly appreciated!
0
Comment
Question by:Insr33
3 Comments
 
LVL 8

Assisted Solution

by:jawa29
jawa29 earned 62 total points
Comment Utility
Hi Insr33

This script should do what you need, this will only export people that have a live account and have something in their Mobile field.

Jawa29
Const ForWriting = 2

Set oRoot = GetObject("LDAP://RootDSE")
vDomain = oRoot.Get("DefaultNamingContext") 

Set oConnection = CreateObject("ADODB.Connection")
Set oCommand =   CreateObject("ADODB.Command")
oConnection.Provider = "ADsDSOObject"
oConnection.Open "Active Directory Provider"
Set oCommand.ActiveConnection = oConnection
oCommand.Properties("Page Size") = 1000

oCommand.CommandText = "<LDAP://" & vDomain & ">;(&(!userAccountControl:1.2.840.113556.1.4.803:=65536)((objectCategory=Person)(!mobile='')));" &_
	"givenName,sn,mobile;Subtree"
Set oRS = oCommand.Execute

sTxt = "Firstname,Surname,Logon,Email,Mobile" & vbCrLf
Do While Not oRS.EOF
	sTxt = sTxt & oRS("givenName") & "," & oRS("sn") & "," & oRS("mobile") & vbCrLf
	oRS.MoveNext
Loop

Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oTextFile = oFSO.OpenTextFile("c:\UserExport.txt", ForWriting, True)
oTextFile.WriteLine(sTxt)
oTextFile.Close

Open in new window

0
 
LVL 17

Accepted Solution

by:
Premkumar Yogeswaran earned 63 total points
Comment Utility
Hi,

i have a simple query in DS command to achieve this task.

dsquery * -filter "(&(objectCategory=person)(objectClass=user)(!userAccountControl:1.2.840.113556.1.4.803:=2))" -limit 0 -attr displayName mobile > c:\User_mobile.txt

Just copy paste the above query in the system with ADMINPAK installed. it will pull the data and save in c:\user_mobile text ffile.

Please let me know if you have any issue in the same.

Note: this will only pull the active users, not the disabled user

Regards,
Prem
dsquery * -filter "(&(objectCategory=person)(objectClass=user)(!userAccountControl:1.2.840.113556.1.4.803:=2))" -limit 0 -attr displayName mobile > c:\User_mobile.txt

Open in new window

0
 

Author Closing Comment

by:Insr33
Comment Utility
both are good solutions.. thx
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Setting up a Microsoft WSUS update system is free relatively speaking if you have hard disk space and processor capacity.   However, WSUS can be a blessing and a curse. For example, there is nothing worse than approving updates and they just have…
A quick step-by-step overview of installing and configuring Carbonite Server Backup.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now