remove share permission from everyone to authenticated user.

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


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