Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Need a script to see all mobile telephone users on domain

Posted on 2011-03-22
3
Medium Priority
?
447 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

On July 14th 2015, Windows Server 2003 will become End of Support, leaving hundreds of thousands of servers around the world that still run this 12 year old operating system vulnerable and potentially out of compliance in many organisations around t…
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

715 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