Grant access to specific folder on Windows devices
  • 02 Feb 2024
  • 1 Minute to read
  • PDF

Grant access to specific folder on Windows devices

  • PDF

Article Summary

This PowerShell script helps IT Admins to grant full access to a specific folder for a user account on their managed Windows devices.

  1. Create a file on your desktop, for example, grant_specific_folder_access.ps1 and open it in a text editor like notepad++

  2. Copy the contents below to the file or click here to download the file.

    #This script will grant full control to user on specified folder
    
    #change folder path and username as per environment
    $path = "path_of_the_folder"
    $username = "user_name"
    
    $acl = Get-Acl $path
    $accessrule = New-Object System.Security.AccessControl.FileSystemAccessRule($username, "FullControl", "ContainerInherit,ObjectInherit", "None", "Allow")
    $acl.SetAccessRule($accessrule)
    
    #set acl on root folder
    Set-Acl $path $acl
    #set acl on sub folders/files in recursive manner
    Get-ChildItem -Path "$path" -Recurse -Force | Set-Acl -AclObject $acl
  3. Add the folder path to which you would like to give access to and the user account name in the above script. For example,

    $path = "C:\DemoFolder"
    $username = "testuser"
  4. Follow our guide to upload & publish the PowerShell script using Scalefusion Dashboard.

Please note that to use the PowerShell scripts, the Scalefusion MDM Agent Application must be installed on the device(s). Please follow our guide to publish and install the Scalefusion MDM Agent Application.

Notes:

  1. The scripts and their contents are sourced from various albeit authenticated Microsoft sources and forums.

  2. Please validate the scripts on a test machine before deploying them on all your managed devices.

  3. Scalefusion has tested these scripts, however, Scalefusion will not be responsible for any loss of data or system malfunction that may arise due to the incorrect usage of these scripts.


Was this article helpful?