Please help me with this Powershell code cant solve it

Hi @gopal.sys.adm

First install the module:
NTFSSecurity 4.2.4

Or, you can try with the following in PowerShell:

# Install the module
Install-Module -Name NTFSSecurity -RequiredVersion 4.2.4

# Import Module
Import-Module NTFSSecurity

I used this file for my environment like the following making sure the users exist in the domain as the Share folders:

FolderName;AccountName;AccessRight;Inherited
\\SADC01\Share\subFolder;domain\User1;Modify, Synchronize;True
\\SADC01\Share\subFolder;domain\User2;FullControl;True

Then the script:

$PermissionList = Import-Csv -Delimiter ";" -Path C:\Users\Administrator\csvtest.csv

foreach($item in $PermissionList){
    $FolderName = $item.FolderName
    $AccountName = $item.AccountName
    $AccessRight = $item.AccessRight
    $Inherit = $item.Inherited

    Get-Item $FolderName | Add-NTFSAccess -Account $AccountName -AccessRights $AccessRight
    
}

Ricardo

Thanks for the reply. It was very helpful. Thank you.

1 Like