Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add group "Everyone" to directory and all of it's sub-directories

I'm currently using Vista 32-bit. How do I add the Windows security group "Everyone" and give full control to a directory and all of it's sub-directories and all files? Is there a powershell script that I could use?

Thanks!

like image 507
tempid Avatar asked Dec 16 '10 19:12

tempid


People also ask

How do I chmod all folders and subfolders?

Changing permissions with chmod To modify the permission flags on existing files and directories, use the chmod command ("change mode"). It can be used for individual files or it can be run recursively with the -R option to change permissions for all of the subdirectories and files within a directory.

How do I give permission to subfolders and files?

From the Advanced Security Settings dialog box, click Add. In the Select User Or Group dialog box, enter Everyone and click OK. In the Permission Entry dialog box, check the Full Control box, choose Subfolders Only from the Apply Onto list, and then click OK.

How do I change folder permissions and subfolders?

Use chmod -R 755 /opt/lampp/htdocs if you want to change permissions of all files and directories at once. Use find /opt/lampp/htdocs -type d -exec chmod 755 {} \; if the number of files you are using is very large.


1 Answers

I've expanded on martona's snippet and was able to give access to all folders and sub-folders. Here's my code -

$FilesAndFolders = gci "c:\data" -recurse | % {$_.FullName}
foreach($FileAndFolder in $FilesAndFolders)
{
    #using get-item instead because some of the folders have '[' or ']' character and Powershell throws exception trying to do a get-acl or set-acl on them.
    $item = gi -literalpath $FileAndFolder 
    $acl = $item.GetAccessControl() 
    $permission = "Everyone","FullControl","Allow"
    $rule = New-Object System.Security.AccessControl.FileSystemAccessRule $permission
    $acl.SetAccessRule($rule)
    $item.SetAccessControl($acl)
}
like image 52
tempid Avatar answered Sep 22 '22 18:09

tempid