• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 426
  • Last Modified:

Local Profiles on workstations

Hello,
    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.

Thanks,
Mike E.
0
mikeeubank
Asked:
mikeeubank
1 Solution
 
TheCleanerCommented:
They asked this on The Scripting Guy pages on MS.

http://www.microsoft.com/technet/scriptcenter/resources/qanda/jun05/hey0603.mspx

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 :          ARobson@scotborders.gov.uk              
' Email Home :          robbo@blakehop.demon.co.uk              
'                                            
' 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)
QDF.Execute
 
' ** 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    
next
Segments = 100 / MyCounter
'LoginBox.SetImage("d:\allan\Vbscript\downloads\homedir_report\sbc_logo.bmp")
loginbox.settitle("Scottish Borders Council")
LoginBox.SetWelcomeMessage("Scanning For User Profiles")
loginbox.setwaitmessage("Please Be Patient this may take a while")
LoginBox.Start

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

For Each oUser in oIADS
 if oUser.Class = "User" then
     myseg = myseg + segments
     rs.addnew
     ' *** display text in dialog box ********    
     tx = oUser.name + VBCRLF
     tx = tx + oUser.fullname + VBCRLF
     tx = tx + oUser.description + vbcrlf
     tx = tx + oUser.loginscript + vbcrlf
     loginbox.setdisplaymessage(tx)
      ' *****************

     
     rs.fields("username").value = oUser.name
     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)
     else
          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)
     else
          rs.Fields("homedirectory").value = "None"
          rs.Fields("homedirectory_size").value = cLng("0")
     end if

     rs.update
     loginbox.pbar(Myseg)
 End If

Set f = Nothing
Next
loginbox.kill

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

===============================================================================
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now