For a sysadmin roaming profiles are both a blessing and a curse.
In time they tend to grow and grow…
The roaming profile size problem results in: long logon and logoff times, corrupted profiles, etc.
This script enumerates the roaming profile size of all users in your Active Directory domain.
By adding extra attributes to the arrAttributes array you can change the output.

Follow the next steps to run the script (admin rights needed for access to the roaming profiles directory):

* open your favorite text editor
* copy and paste the script into the editor
* save the script (for example c:\temp\roamingprofilesize.vbs)
* open a command prompt
* go to “c:\temp”
* give “cscript roamingprofilesize.vbs” (without quotes) and enter

The script:

' Name : roamingprofilesize.vbs
' Description : script to enumerate the roaming profile size of all users in Active Directory
' Author : dirk adamsky - deludi bv
' Version : 1.00
' Date : 15-03-2010
' Level : intermediate

arrAttributes = Array("profilePath","displayname","mail") 

Set adoCommand = CreateObject("ADODB.Command")
Set adoConnection = CreateObject("ADODB.Connection")
adoConnection.Provider = "ADsDSOObject"
adoConnection.Open "Active Directory Provider"
adoCommand.ActiveConnection = adoConnection

Set objRootDSE = GetObject("LDAP://RootDSE")
strBase = "<LDAP://" & objRootDSE.Get("defaultNamingContext") & ">"
Set objRootDSE = Nothing

strFilter = "(&(objectCategory=person)(objectClass=user)(profilePath=*))"
strAttributes = Join(arrAttributes,",")
Wscript.Echo Join(arrAttributes,";") & " ; roaming profile size in MB"
strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
adoCommand.CommandText = strQuery
adoCommand.Properties("Page Size") = 100
adoCommand.Properties("Timeout") = 30
adoCommand.Properties("Cache Results") = False
Set adoRecordset = adoCommand.Execute
Do Until adoRecordset.EOF
	On Error Resume Next
	strTempOutput = ""
	For i = 1 To Ubound(arrAttributes)
		strTempOutput =  strTempOutput & " ; " & adoRecordset.Fields(arrAttributes(i)).Value
		strOutput = Mid(Ltrim(strTempOutput),3)
	Next
	Wscript.Echo strOutput & " ; " & Foldersize (adoRecordset.Fields(arrAttributes(0)).Value) & " MB"
	adoRecordset.MoveNext
Loop
adoRecordset.Close
adoConnection.Close
Set adoRecordset = Nothing
Set adoConnection = Nothing
Set adoCommand = Nothing

Function Foldersize(strPath)
	On Error Resume Next
	Set objFSO = CreateObject("scripting.filesystemobject")
	Set objFld = objFSO.GetFolder(strPath)
	Foldersize = Round(objFld.Size/1048576,2)
	Set objFld = Nothing
	Set objFSO = Nothing
End Function

When you have problems/questions please post a reply. Also can alo give a ‘star’ rating.

Happy scripting.

Best regards,

Dirk Adamsky – Deludi BV

VN:F [1.9.3_1094]
Rating: 10.0/10 (1 vote cast)
VN:F [1.9.3_1094]
Rating: 0 (from 0 votes)

The motto of the day is: Recursion rules.
A couple of years ago I have done quite a few Filesystem Object scripts.
To refresh my mind I have made some new filesystem scripts.
This is the first one: a simple subroutine that uses recursion to enumrate all subfolders of a folder.
The subroutine needs one argument: the path of the folder.
The path can be local (“c:\temp”) or an UNC path like “\\server\test”.

Follow the next steps to run the script (admin rights needed on the folder you want to enumerate):

  • open your favorite text editor
  • copy and paste the script into the editor
  • change the path of the folder to your folder path
  • save the script (for example c:\temp\enumeratesubfolders.vbs)
  • open a command prompt
  • go to “c:\temp”
  • give “cscript enumeratesubfolders.vbs” (without quotes) and enter

The script:

' Name : enumeratesubfolders.vbs
' Description : script to enumerate all subfolders (recursive) of a given folder
' Author : dirk adamsky - deludi bv
' Version : 1.00
' Date : 05-03-2010
' Level : Intermediate

ViewSubFolders "c:\temp"
Sub ViewSubFolders(strFolder)
	Set objFSO = CreateObject("Scripting.FileSystemObject")
	Set objFolder = objFSO.GetFolder(strFolder)
	For Each SubFolder in objFolder.SubFolders
		Wscript.Echo SubFolder.Path
		ViewSubFolders SubFolder
	Next
	Set objFolder = Nothing
	Set objFSO = Nothing
End Sub

When you have problems/questions please make a reply, when you like the script please rate it with the star rating below.

Happy scripting.

Best regards,

Dirk Adamsky – Deludi BV

VN:F [1.9.3_1094]
Rating: 10.0/10 (1 vote cast)
VN:F [1.9.3_1094]
Rating: 0 (from 0 votes)
© 2010 Dirk Adamsky Scripting Blog Suffusion WordPress theme by Sayontan Sinha