Adding and Removing permissions from shared folder

Ask your Windows 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.
Post Reply
User avatar
sekou2331
Posts: 260
Joined: Wed Aug 15, 2012 6:07 am

Adding and Removing permissions from shared folder

Post by sekou2331 » Thu Sep 13, 2018 5:33 am

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.  
  3. icacls \\%%a\folder /remove:g Everyone
  4.  
  5. icacls \\%%a\folder\logs /remove:g Everyone
  6.  
  7. icacls \\%%a\folder\logs /remove:g user
  8.  
  9. icacls \\%%a\folder\ /grant "Security Group":R
  10.  
  11. )
  12.  
  13.  

User avatar
jvierra
Posts: 12678
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Adding and Removing permissions from shared folder

Post by jvierra » Thu Sep 13, 2018 8:52 am

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: 260
Joined: Wed Aug 15, 2012 6:07 am

Re: Adding and Removing permissions from shared folder

Post by sekou2331 » Thu Sep 13, 2018 2:32 pm

Ok what I am truly asking is this the right route for changing permissions on a shared folder?

User avatar
jvierra
Posts: 12678
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Adding and Removing permissions from shared folder

Post by jvierra » Thu Sep 13, 2018 2:48 pm

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.

Post Reply