Local Profiles on workstations

Posted on 2006-06-06
Last Modified: 2008-01-09
    Can anyone help me with a scripting question? I need a script than can be run remotely against a workstation that will enumerate (list) all of the local and domain profiles on a box as well as thier sizes. I am on a PC deployment and want to limit the number of profiles on these machines (many of which are shared) so that the tool I run to migrate data does not take hours copying over data from old profiles.

Mike E.
Question by:mikeeubank
    1 Comment
    LVL 23

    Accepted Solution

    They asked this on The Scripting Guy pages on MS.

    But as far as sizes goes, it doesn't do that...

    however, I did find an old script that supposedly does it and creates an Access Database with the information.  I haven't ever used it so be cautious, but it may give you all that you are looking for:


    ' Title :          Customer Support Officer              
    ' Location :          Scottish Borders Council              
    ' Email Work :              
    ' Email Home :              
    ' Get the size of all users Profile & Home directories from the domain    
    ' and insert this info info an access database.                    
    ' This script requires WSH,ADSI,VB5 Runtime and Loginbox activX tool    
    ' as well as Access97 to be installed on the PC the script is run from    
    ' Version 1.1 Freeware
    ' Any Changes Must be reported to the Auther at his home Email address
    ' Access Database Structure
    ' Database Author: profiles.mdb
    ' Table Author: Domain_users
    ' Fields:     Author:               Type:    
    ' F1           UID               AutoNumber
    ' F2          UserName          Text:50
    ' F3          FullName          Text:50
    ' F4          Description          Text:150
    ' F5          LoginScript          Text:150
    ' F6          Profile               Text:150
    ' F7          Profile_Size          Number
    ' F8          HomeDirectory          Text:150
    ' F9          HomeDirectory_Size     Number

    ' REMEMBER TO CHANGE THE DOMAIN NAME                          **
    dim DomainName
    DomainName = "greiernet"


    Dim oIADS, fsi, f
    Dim fso, a
    Dim objacc
    Dim objdb
    Dim rs
    Dim objdbe
    Dim MyCounter

    ' Setup Environment and Create objects ********

    Set WSHSHELL = WScript.CreateObject("Wscript.Shell")
    'Set LoginBox = WScript.CreateObject("Loginscreen.Main")
    Set objacc = WScript.CreateObject("Access.Application")
    Set objdbe = objacc.DBEngine
    Set objdb = objdbe.OpenDatabase("c:\ftp\public\utilities\scripts\profilesize\profiles.mdb")
    Set rs = objdb.OpenRecordset("domain_users")

    ' ** delete old records from database

    strSQL = "delete * from domain_users"
    set QDF = objdb.CreateQueryDef("",strSQL)
    ' ** setup user and file object ********
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set a = fso.CreateTextFile("c:\dirsize.csv")
    Set fsi = CreateObject("Scripting.FileSystemObject")

    ' ** get NT domain info ***********
    Set oIADS = GetObject("WinNT://" & DomainName)

    On Error resume next

    ' **** setup dialog box to display ********

    For Each oUser in oIADS
         if oUser.Class = "User" then
              MyCounter = MyCounter + 1
         end if    
    Segments = 100 / MyCounter
    loginbox.settitle("Scottish Borders Council")
    LoginBox.SetWelcomeMessage("Scanning For User Profiles")
    loginbox.setwaitmessage("Please Be Patient this may take a while")

    ' **** get user info and add to database *********

    For Each oUser in oIADS
     if oUser.Class = "User" then
         myseg = myseg + segments
         ' *** display text in dialog box ********    
         tx = + VBCRLF
         tx = tx + oUser.fullname + VBCRLF
         tx = tx + oUser.description + vbcrlf
         tx = tx + oUser.loginscript + vbcrlf
          ' *****************

         rs.fields("username").value =
         rs.fields("Fullname").value = oUser.fullname
         rs.fields("description").value = oUser.description
         rs.fields("loginscript").value = oUser.loginscript
         if trim(oUser.profile) <> "" then
              Set f = fsi.GetFolder(oUser.profile)
              rs.fields("profile").value = oUser.profile
              rs.fields("Profile_size").value = CLng(f.size / 1024)
              rs.fields("profile").value = "None"
              rs.fields("Profile_size").value = cLng("0")
         end if
         if trim(oUser.HomeDirectory) <> "" then
              Set g = fsi.GetFolder(oUser.HomeDirectory)
              rs.Fields("homedirectory").value = oUser.homedirectory
              rs.Fields("homedirectory_size").value = cLng(g.size / 1024)
              rs.Fields("homedirectory").value = "None"
              rs.Fields("homedirectory_size").value = cLng("0")
         end if

     End If

    Set f = Nothing

    set loginbox = nothing
    set rs = nothing
    set objdb = nothing


    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    by Batuhan Cetin Within the dynamic life of an IT administrator, we hold many information in our minds like user names, passwords, IDs, phone numbers, incomes, service tags, bills and the order from our wives to buy milk when coming back to home.…
    ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    730 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

    16 Experts available now in Live!

    Get 1:1 Help Now