Get and Set Security Groups

User avatar
ErikJan
BronzeLounger
Posts: 1228
Joined: 03 Feb 2010, 19:59
Location: Terneuzen, the Netherlands

Get and Set Security Groups

Post by ErikJan »

Looking for a script (or VBA code?) where I can:
(1) Get the security applied to files and folders. So I mean per file, the people and groups who have access and what type of access
(2) Set the security to certain people and groups. E.g. Jim and Sara get Read/Write and the Users1 group get Read Only

For the latter, I'd like to be able to re-apply at the top level and restore inheritance downward so I only need to call this once and then all files and folders below get the new security settings applied.

User avatar
HansV
Administrator
Posts: 78369
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Get and Set Security Groups

Post by HansV »

I'm not into this kind of stuff, but perhaps the following will help:

Active Directory Administration with Windows PowerShell
Get-ADGroupMember
Add-ADGroupMember
Best wishes,
Hans

User avatar
ErikJan
BronzeLounger
Posts: 1228
Joined: 03 Feb 2010, 19:59
Location: Terneuzen, the Netherlands

Re: Get and Set Security Groups

Post by ErikJan »

I don't want to change security groups themselves, I only want to SEE what is applied for each file/folder and (later) I want to apply certain groups and users to files.

So in the picture I want to see which "Group or user names" are in effect for this file and for each group I want to see what the permissions are (and change these separately).
It's easy by hand using the "Security" tab but can I automate this in e.g. VBA?
Projects 2017.xlsx Properties.png
.
You do not have the required permissions to view the files attached to this post.

User avatar
HansV
Administrator
Posts: 78369
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Get and Set Security Groups

Post by HansV »

You may have better luck asking your question in Microsoft's PowerShell Forum.
Best wishes,
Hans

User avatar
John Gray
PlatinumLounger
Posts: 5403
Joined: 24 Jan 2010, 08:33
Location: A cathedral city in England

Re: Get and Set Security Groups

Post by John Gray »

Wading through displayed permissions is immensely tedious because there is so much data produced.

Google for "NTFS Permissions Reporter" and take your pick!
John Gray

"(or one of the team)" - how your appointment letter indicates you won't be seeing the Consultant...

User avatar
ErikJan
BronzeLounger
Posts: 1228
Joined: 03 Feb 2010, 19:59
Location: Terneuzen, the Netherlands

Re: Get and Set Security Groups

Post by ErikJan »

ICACLS seems interesting

User avatar
John Gray
PlatinumLounger
Posts: 5403
Joined: 24 Jan 2010, 08:33
Location: A cathedral city in England

Re: Get and Set Security Groups

Post by John Gray »

ICACLS is the successor to CACLS, both being "built-in" utilities.

It took me quite some time to understand the bizarre nature of their parameters!
John Gray

"(or one of the team)" - how your appointment letter indicates you won't be seeing the Consultant...

User avatar
ErikJan
BronzeLounger
Posts: 1228
Joined: 03 Feb 2010, 19:59
Location: Terneuzen, the Netherlands

Re: Get and Set Security Groups

Post by ErikJan »

icacls <folder> /reset /T Would reset everything
icacls <folder> /T Would list everything

At least, that how it seems... Guess I can start playing with this.