remove share permission from everyone to authenticated user.

This topic contains 1 reply, has 2 voices, and was last updated by Profile photo of E Y E Y 5 months, 3 weeks ago.

  • Author
  • #38068
    Profile photo of Dawit

    Hi Powershell gurus,

    I'm fairly new to powershell, I 've a business need to remove the "everyone" permission both from the NTFS and file permission and replace it with Authenticated user. the shares are located in different site and domain. I'm planning on running the script from a management server that has access to the shares. I found the following script but turn with a bunch of errors, any help will be greatly appreciated.

    foreach($share in (Get-WmiObject win32_share |?{$ -notmatch "C\$|ADMIN\$|IPC\$|NETLOGON SYSVOL"} | select -expandProperty Name))
    #get settings
    $set = get-wmiobject -Class Win32_LogicalshareSecuritySetting -filter "Name='$share'"

    #filter Everyone out
    $revised = $set.GetSecurityDescriptor().Descriptor.Dacl | Where {$ -ne 'Everyone'}

    #set the new ACL
    $descriptor = $set.GetSecurityDescriptor().descriptor
    $descriptor.dacl = $revised

  • #38590
    Profile photo of E Y
    E Y

    The CMDLets in the NTFSSecurity Module should be exactly what you need:

You must be logged in to reply to this topic.