0

I am currently trying to add a group called "Domain Admins" to all fileshares, we have over 300. I would like to automate this so I don't have to do this manually for each one, and would then like to remove the local administrator group from each fileshare as well.

I currently am able to get all fileshares names and permissions of each one with:

    $shares = Get-SmbShare


foreach($share in $shares) {
    $share
    (get-smbshare $share.Path)| select @{Label="Path"; Expression = { Convert-Path $_.Path }} -ExpandProperty Access 
} 

But I can't seem to find any resources that demonstrate how to add a group to all fileshares. I know how to add a group to a specific file share, but not all. If anyone can share some tips, that would be great!

Gamblers
  • 41
  • 4
  • 2
    Sounds like you're looking for [`Grant-SmbShareAccess`](https://learn.microsoft.com/en-us/powershell/module/smbshare/grant-smbshareaccess?view=win10-ps) – Mathias R. Jessen Nov 03 '19 at 18:59
  • You already have a listing of all shares, and you have a foreach loop looping through each individual share, and you know how to set permissions for an individual share- so just set permissions inside the loop? – Mark Nov 03 '19 at 23:24
  • I understand your thought process and it seems logical that one would do that. But I can't seem to figure out the proper syntax. For example, when listing the file shares, they are listed in "D:/fileshare" format and when adding a group to said path gives an error. Parsing the "D:/" and setting just the file share name to a variable, then adding the group to said share via fileshare name still gives an error. So I am stumped. – Gamblers Nov 09 '19 at 14:56

0 Answers0