Joseph Michael Pesch
VP Programming

Powershell Script to set full access to folders in Windows

by 28. May 2022 18:30

Powershell Script to set full access to folders in Windows:

 

$AccessRule = New-Object System.Security.AccessControl.FileSystemAccessRule("user_name","FullControl","Allow")

function Get-Folders {

    param($path)

    $list = ''

    $comma = ""

    foreach ($folder in Get-ChildItem -Path $path -Recurse -Directory) {

        Write-Output $folder.FullName

        $ACL = Get-ACL -Path $folder.FullName

        $ACL.SetAccessRule($AccessRule)

        $ACL | Set-Acl -Path $folder.FullName

        Get-Folders $folder.FullName

    }

}

Get-Folders 'C:\ProgramData\Docker'

Tags:

Windows

Comments are closed