folders

Take Ownership of paths from PowerShell

Posted by robd on April 25, 2023
powershell / No Comments

Hello,

Had a requirement to take ownership of a long list of windows file paths which were conviently in a csv file like this:

path

\\domain.local\site\users\User.Name\

So I used the following PowerShell and NTFSSecurity module.

#import this first (run powershell as Admin)
#Install-Module -Name NTFSSecurity

#Fill out the csv with all the paths you want to change

Import-CSV "C:\Temp\scripts\permissions.csv" |
    ForEach-Object{
    Add-NTFSAccess -Path $_.path -Account admin@domain.com -AccessRights FullControl
    Set-NTFSOwner -Path $_.path -Account  admin@domain.com

    }

 

Tags: , ,