Solved

Need a script to see all mobile telephone users on domain

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

710 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