Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Need a script to see all mobile telephone users on domain

Posted on 2011-03-22
3
Medium Priority
?
450 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 248 total points
ID: 35191174
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 252 total points
ID: 35195916
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
ID: 35205149
both are good solutions.. thx
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
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…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

963 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