Adding and Removing permissions from shared folder

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 5 years and 6 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
sekou2331
Posts: 318
Last visit: Sat Oct 28, 2023 7:46 am

Adding and Removing permissions from shared folder

Post by sekou2331 »

I am trying to find the equivalent to the below in powershell. I see that there is a cmdlet called Get-ACL but I dont see a modifying cmdlet.

  1. for /f %%a in (servers.txt) do (
  2. icacls \\%%a\folder /remove:g Everyone
  3. icacls \\%%a\folder\logs /remove:g Everyone
  4. icacls \\%%a\folder\logs /remove:g user
  5. icacls \\%%a\folder\ /grant "Security Group":R
  6. )
  7.  
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Adding and Removing permissions from shared folder

Post by jvierra »

When you need companion CmdLets use help to find them.

help get-acl -online

The help will list the paired commands and will give you examples.
User avatar
sekou2331
Posts: 318
Last visit: Sat Oct 28, 2023 7:46 am

Re: Adding and Removing permissions from shared folder

Post by sekou2331 »

Ok what I am truly asking is this the right route for changing permissions on a shared folder?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Adding and Removing permissions from shared folder

Post by jvierra »

On a folder or on a share? You cannot use either to alter a share. Both only change the underlying folder.
ICACLS works correctly in PowerShell. No need to change it.
This topic is 5 years and 6 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked