[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

VBScript - User Account Usage ( Least used accts, most frequently used accts)

Posted on 2007-11-21
11
Medium Priority
?
1,265 Views
Last Modified: 2008-02-22
I need a VBScript to report on user acct usage (URGENTLY..)

It -must- report on the following two things (anything additional + relevant is cool)

 - Most frequently used account
 - Least frequently used


I've attached the following code, dont know if it will work because I cant test. It's as far as I got without being completely stumped.

500 Points and a BIG AWESOME THANK YOU to anyone that helps in advance.. I have to hand this in in about .. 9 hours so I hope someone can finish my code
'To check the login time and disable the account
Dim dDate, oUser, oObject, oGroup
Dim iFlags, iDiff, iResult
dim arrweeks()
Const UF_ACCOUNTDISABLE = &H0002
 
'Point to group containing users to check
Set oGroup = GetObject("WinNT://MyDomain/Domain Users")
'Enable error trapping
 
On error resume Next
 
'for each user object in the group...
For each oObject in oGroup.Members
x = x + 1
  'ensure the user isn't a computer account!
  If (oObject.Class="User") And _
  (InStr(oObject.Name, "$") = 0) Then
     'retrieve the user object
     Set oUser = GetoObject(oObject.ADsPath)
     'get the last login Date from the domain
     'and strip off the time portion
     '(just need the date)
     dDate = oUser.get("LastLogin")
     dDate = Left(dDate,8)
     dDate = CDate(dDate)
 
     'calculate how long ago that was in weeks
     iDiff = DateDiff("ww", dDate, Now)
 
     'store into an array
 
     arrweeks(x) = idiff
     arrusername(x) = oObject.Name
 
     End If
  End If
Next
 
Do until strcount = 1
y = y + 1
	If arrusername = "" then
	strcount = 1
	else
	msgbox "account name" & vbtab & arrusername(y) & vbcrlf & _
		"how long since last login (weeks)" & vbtab & arrweeks(y) "
	End If
Loop

Open in new window

0
Comment
Question by:dshocker
[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
  • 2
  • 2
  • +3
11 Comments
 
LVL 12

Expert Comment

by:chandru_sol
ID: 20327014
Hi,

Do you want to know the last login details?

If you have 2003 domain we can pull the lastlogin details to see who are the users that are not logged in before x days.

regards
Chandru
0
 
LVL 6

Expert Comment

by:MorDrakka
ID: 20327029
Hi,

Can't you do things the other way around ? So for example list all users that haven't logged in for say 20 weeks:

dsquery user ou=users,ou=nl,dc=microsoft,dc=com -inactive 20 -limit 0

Add >>output.txt to put it into a textfile.

Regards,

M
0
 

Author Comment

by:dshocker
ID: 20327089
Argh I don't even know about that script, lol.

I just need it to show simply in a msgbox the LEAST used account, and the most frequently used account..

Once I get that script I can think about like, last 5 logged in accts and stuff x_O
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 29

Accepted Solution

by:
Michael Pfister earned 672 total points
ID: 20327104
You won't get that info from Active Directory. Its not counting the number of logons, just date and time when the user logs on.
0
 
LVL 6

Assisted Solution

by:MorDrakka
MorDrakka earned 664 total points
ID: 20327133
And that's sonly stored on the DC that processed that request. That information is not replicated.

So i suggest you play with dsquery :P

M.
0
 

Author Comment

by:dshocker
ID: 20327235
MPFister? Okay, then it must be locally?????
0
 

Author Comment

by:dshocker
ID: 20327270
Oh, sorry I misunderstood, hehe.

Ugh.


Yeah, I have no idea..

Could someone play with my code and get it to work? :S
0
 
LVL 19

Assisted Solution

by:SteveH_UK
SteveH_UK earned 664 total points
ID: 20334849
MorDrakka is right in saying that it is only stored on the DC that processed the request.

Here's how I'd go about it.

1.  See if you can delimit user accounts somehow, such as membership of a group or containment in an OU.
2.  Use dsquery to search and retrieve the users and their last logon details
3.  Either output to Excel or use script
4.  Sort on the basis of logon date/time
5.  Trim to the ones you want
0
 
LVL 19

Expert Comment

by:SteveH_UK
ID: 20334854
Forgot to mention that you need to repeat the search for each DC in each site accessible to the user.  If you are a large organisation then that will be a lot of searching, but if you are small it will be pretty simple.
0
 
LVL 1

Expert Comment

by:Computer101
ID: 20962204
Forced accept.

Computer101
Community Support Moderator
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

We recently endured a series of broadcast storms that caused our ISP to shut us down for brief periods of time. After going through a multitude of tests, we determined that the issue was related to Intel NIC drivers on some new HP desktop computers …
This is the first one of a series of articles I’ll be writing to address technical issues that are always referred to as network problems. The network boundaries have changed, therefore having an understanding of how each piece in the network  puzzl…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

649 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