[THIN] Re: OT: script bulk NTFS changes

  • From: "Landin, Mark" <Mark.Landin@xxxxxxxxxxxxxxxx>
  • To: <thin@xxxxxxxxxxxxx>
  • Date: Mon, 13 Dec 2004 11:18:18 -0600

I find fileACL is an excellent tool. You don't have to program it, for
one. :) It can even "snapshot" your existing ACL's, so you have them for
things like replicating them on new servers, using them as templates for
new directories, or even for disaster recovery. It's got a COM interface
now too, in case you just INSIST on programming something. :)

http://membres.lycos.fr/jfb/gb/gbtools/fileacl.htm

 

> -----Original Message-----
> From: thin-bounce@xxxxxxxxxxxxx 
> [mailto:thin-bounce@xxxxxxxxxxxxx] On Behalf Of Andrew Wood
> Sent: Monday, December 13, 2004 10:48 AM
> To: thin@xxxxxxxxxxxxx
> Subject: [THIN] Re: OT: script bulk NTFS changes
> 
> Pavlo
> 
> If you want to do ACL management from scripts take a look at 
> the freeware SETACL which is a very powerful tool 
> (http://setacl.sourceforge.net/)
> 
> You can use two methods to move down the folder structure 
> depending on the OS. W2k3 and XP allow you to use a LIKE 
> structure; Windows 2000 doesn't allow like - so it's a 
> recursive procedure.
> 
> 
> ============== START W2k3/XP version using LIKE strComputer="."
> strFolderRoot="c:\\temp"
> 
> Set objWMIService = GetObject("winmgmts:" _
>       & "{impersonationLevel=impersonate}!\\" & strComputer & 
> "\root\cimv2") Set colFolders = objWMIService.ExecQuery _
>       ("Select * from Win32_Directory where Name Like '" & 
> strFolderRoot &
> "%'")
> 
> For Each objFolder in colFolders
> 
>   ' The file query process needs to have folder names 
> separated by double
>   ' slashes
>   strTMP = Replace(Mid(objFolder.Name,4,Len(objFolder.Name)),"\","\\")
> 
>   strQuery = "SELECT * FROM CIM_DataFile WHERE Drive = '" &
> left(strFolderRoot,2) & "'" & _
>                "AND Path = '\\" & strTMP & "\\'"
> 
>   Set colFiles = objWMIService.ExecQuery(strQuery)
>   For Each objFile in colFiles
>     WScript.Echo objFolder.Name & "," & objFile.Name & "," &
> GetVBDate(objFile.LastModified)
>   Next
> Next
> 
> '
> ' Tidy up the WMI date format to be readable for mere mortals '
> Function GetVBDate(wd)
>   GetVBDate = DateSerial(left(wd,4),mid(wd,5,2),mid(wd,7,2)) _
>        + TimeSerial(mid(wd,9,2),mid(wd,11,2),mid(wd,13,2))
> End Function   
> ============== END START W2k3/XP version using LIKE
> 
> 
> 
> ==========START W2k version using recursive procedures 
> strFolderRoot = "c:\temp"
> ' Get instance of FileSystemObject.
> Set fso = CreateObject("Scripting.FileSystemObject")
> ShowSubfolders FSO.GetFolder(strFolderRoot)
> 
> Set fso = Nothing
> Wscript.Quit
> 
> '
> ' Recursive Procedure to show all files and folders within a 
> given folder.
> '
> Sub ShowSubFolders(Folder)
> 
>    set ofso = CreateObject("Scripting.FileSystemObject")
>     For Each objFile in Folder.Files
>       If ofso.FileExists(objFile.path) Then
>        WScript.Echo folder.path & "," & objFile.Name & "," & 
> objFile.DateLastModified
> 
>        if ofso.FileExists(strLogFile) Then
>               ofso.deletefile(strLogFile)
>        End If
> 
>       End If
>     Next
> 
>     For Each Subfolder in Folder.SubFolders
>         ShowSubFolders Subfolder
>     Next
> 
> End Sub
> 
> ==========END
> 
> Hope this helps.
> 
> 
> -----Original Message-----
> From: thin-bounce@xxxxxxxxxxxxx 
> [mailto:thin-bounce@xxxxxxxxxxxxx] On Behalf Of Jay Jukes
> Sent: 13 December 2004 14:02
> To: thin@xxxxxxxxxxxxx
> Subject: [THIN] Re: OT: script bulk NTFS changes
> 
> Would Dumpsec help you here? (it produces a report of the 
> existing ACLs) http://www.somarsoft.com/
> 
> 
> 
> -----Original Message-----
> From: thin-bounce@xxxxxxxxxxxxx 
> [mailto:thin-bounce@xxxxxxxxxxxxx] On Behalf Of Pavlo Ignatusha
> Sent: Monday, 13 December 2004 11:18 PM
> To: Org Thin (E-mail)
> Subject: [THIN] OT: script bulk NTFS changes
> 
> Hi list.
> 
> This is a bit off-topic but I know there are script gurus out 
> here that can help me out (and they did a lot in the 
> past-thanks Neil).
> 
> We are migrating users to new accounts in AD. Obviously the 
> NTFS permissions given to old accounts will not work once 
> user is given a new account. I need to change ACL for all the 
> files and folders. Current NTFS permissions are mess, some 
> inheritance is there but lots of manual setting per user 
> exist...I would like to script bulk NTFS changes like this:
> 
> 1. have source file that I feed the script with. This way I 
> establish old user account mapping to new account:
> 
> jdoe = John Doe
> pignatusha = Pavlo Ignatusha
> 
> 2. browse file and folder structure and read ACL on every object.
> 3. if user's old account is explicitly there add user's new 
> account to the ACL.
> 
> I sure have no problem creating the user name mapping file. I 
> will figure how to script permission change as well (cacls, 
> setacl, etc). The challenging part is the browse function 
> because I'm not sure how to make script to move along the 
> folder tree structure. This is what I need the most help 
> with. Does anybody has an idea or better yet a sample of how 
> to script through the drive folder structure?
> 
> Thanks,
> 
> Pavlo Ignatusha
> Systems Network Coordinator
> Pembroke General Hospital
> Tel. (613) 732-3675 ext.6150
> Fax. (613) 732-9986
> www.pemgenhos.org
> 
> 
> ********************************************************
> This Weeks Sponsor SeamlessPlanet.com Domain Names Register 
> your .com domain name for as low as $7.85 One of the lowest 
> prices on the web! Part of The Kenzig Group.
> http://www.seamlessplanet.com
> **********************************************************
> Useful Thin Client Computing Links are available at:
> http://thin.net/links.cfm
> ThinWiki community - Awesome SBC Search Capabilities!
> http://www.thinwiki.com
> ***********************************************************
> For Archives, to Unsubscribe, Subscribe or set Digest or 
> Vacation mode use the below link:
> http://thin.net/citrixlist.cfm
> 
********************************************************
This Weeks Sponsor SeamlessPlanet.com Domain Names
Register your .com domain name for as low as $7.85
One of the lowest prices on the web! Part of The Kenzig Group.
http://www.seamlessplanet.com
**********************************************************
Useful Thin Client Computing Links are available at:
http://thin.net/links.cfm
ThinWiki community - Awesome SBC Search Capabilities!
http://www.thinwiki.com
***********************************************************
For Archives, to Unsubscribe, Subscribe or
set Digest or Vacation mode use the below link:
http://thin.net/citrixlist.cfm

Other related posts: