Solved

Need a script to see all mobile telephone users on domain

Posted on 2011-03-22
3
423 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
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 63 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Event ID: 1008 / Source: Microsoft-Windows-Perflib 2 159
Unknown AD user under VMWare OU 4 58
2003 File Server upgrade 11 62
fso.FolderExists("\\server\HiddenFolder$") 4 64
Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
Learn about cloud computing and its benefits for small business owners.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

815 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

10 Experts available now in Live!

Get 1:1 Help Now