I'm writing a script to go through our AD user list and email when people's home areas are over a certain size. The Script works apart from 2 folders. When tried with 2 users it always returns path not found error.
It's almost as if the FolderExists expression returns true, but then the Folder.size method fails because it can't find the same folder.
Any help much appreciated - couldn't find much info on the web about this, folder permissions seem to be fine.
thanks
user="testuser1" pathr="\\pc6-7\h$\R_DrivesA\" & user & "h" pathr2="\\pc6-8\h$\R_DrivesB\" & user & "h"
Set objFSo = CreateObject("Scripting.FileSystemObject")
WScript.Echo("user id " & user)
If objFSo.FolderExists(pathr) Then Wscript.echo(pathr) Set objFolder = objFSO.GetFolder(pathr) WScript.Echo "Dir Exists in R drives" WScript.Echo "Size is " & Gigabyte(objFolder.size) & " GB"
ElseIf objFSo.FolderExists(pathr2) Then Wscript.echo(pathr2) Set objFolder = objFSO.GetFolder(pathr2) WScript.Echo "Dir exists in R drives 2" WScript.Echo "Size is " & Gigabyte(objFolder.size) & " GB"
It crashes out on objFolders.size. The Gigabyte function simply converts bytes to gigabytes, so I can display a more user friendly output. Even if I remove the gigabyte function and just leave objfolder.size it still fails. Alll other users in the "standard systems and users" container work fine. It goes through around 200 user accounts, but crashes out on just 2 folders.
I've done some testing using writeline commands. The paths written to text file are fine, because I can copy and paste then unc paths in drive mappings fine.