Needing help with a script (batch?) file

Status
Not open for further replies.

Digger

Ars Tribunus Angusticlavius
8,017
Hi Gang,

I'm not certain this is the proper place for this, so if it's in the wrong place, apologies please move it.
My boss has asked for some things that fall into the scripting area. Difficulty: I've never scripted anything in my life. Help!

We are a Windows shop, this is what she needs:

1. From a command prompt as whoever runs it, please devise a script that goes out and reads your permissions to the directories under T (T is a network drive) and pipes them to a text file. The purpose is to see where there are rights issues. I’m hearing it’s a huge mess.
2. Another script to text file that searches and lists anything with SOP in the body or file name.

I really have no idea where to begin, we don't have any programmers on our staff so it's up to me (such fun!)
Any help, pointers, wanna write this for me, advice, etc, is *greatly* appreciated!
 
For #1 you probably want to explore Powershell. I'm not sure cmd has a good way of listing off ACLs.

For #2 you probably want to do something like dir /s *SOP*.* > list_of_files_with_sop_in_title.txt. But that won't get you anything with SOP "in the body." I'm guessing by "in the body" you mean like if it's a text file and has SOP somewhere in it? That's quite a bit trickier. For plain text files you can use type filename.txt | findstr SOP. But I imagine the number of plain text files you need to search through are limited.
 

technophile

Ars Legatus Legionis
23,768
[url=http:/civis/viewtopic.php?p=27255725#p27255725:jnmk9ga2 said:
Archangel Mychael[/url]":jnmk9ga2]For #1 you probably want to explore Powershell. I'm not sure cmd has a good way of listing off ACLs.
No scripting required:
Code:
cacls T:\ /C /T > permissions.txt

Code:
 Abbreviations:
    CI - Container Inherit.
         The ACE will be inherited by directories.
    OI - Object Inherit.
         The ACE will be inherited by files.
    IO - Inherit Only.
         The ACE does not apply to the current file/directory.
    ID - Inherited.
         The ACE was inherited from the parent directory's ACL.
 

MarkL

Ars Tribunus Militum
2,008
Subscriptor
Why is there a requirement to have the users run the script themselves and depend on them to send you the results? As an administrator, can't you run the same script and collect the information yourself? Relying on users makes me nervous.

To my knowledge, cacls show ALL ACL's, not just the ACL's for the user running the script. Further, because the target here is a network drive, you will have interaction between the NTFS permissions (listed in the ACL's) and the share permissions which cacls is not going to list. This interaction can lead to some subtle and unexpected results.

If the question is, "who can edit a particular file", I don't think cacls by itself is going to figure that out.
 

Digger

Ars Tribunus Angusticlavius
8,017
[url=http:/civis/viewtopic.php?p=27308657#p27308657:2sk1tyzq said:
MarkL[/url]":2sk1tyzq]Why is there a requirement to have the users run the script themselves and depend on them to send you the results? As an administrator, can't you run the same script and collect the information yourself? Relying on users makes me nervous.

To my knowledge, cacls show ALL ACL's, not just the ACL's for the user running the script. Further, because the target here is a network drive, you will have interaction between the NTFS permissions (listed in the ACL's) and the share permissions which cacls is not going to list. This interaction can lead to some subtle and unexpected results.

If the question is, "who can edit a particular file", I don't think cacls by itself is going to figure that out.

You make some interesting and valid points.
Wish I had answers. I have asked for clarification (from my people) and gotten....none.
 
Status
Not open for further replies.