Forum Discussion

suren424's avatar
suren424
Copper Contributor
Sep 24, 2020

Powershell script to enable inheritance for the folders created in NTFS share

Hi,

 

We have a NTFS Share folder wherein we are creating all the users' homeDirectories (homefolder) within the enterprise using Oracle identity management tool. Homefolder creation is working good. But, we are having issues with the permissions.

 

-- It doesn't inherit permissions from the parent folder.

-- sometimes the owner also doesn't get the permissions.

 

Is there a way for us to check the current permissions and enable inheritance for the folders created in the share and all the child items within. We have a lot of homefolders and not able to figureout how to do it via Powershell.

 

Any input will be greatly appreciated.

 

Thanks in advance.

 

 

 

  • suren424 

    You can use this example

     

    $x=Get-ItemProperty -Path C:\MyFolder\123\456
    Write-Host "The Parent is " -ForegroundColor Green -NoNewline
    $x.Parent.Name

    if the answer fulfill your needs, please don't forget to click on Best Response and give a like 🙂

    Thanks

     

    • suren424's avatar
      suren424
      Copper Contributor

      Thanks for the quick response farismalaeb

       

      I was doing some research and network share folder we need to have 'NTFSSecurity ' powershell module. Do i have to use cmdlets from 'NTFSSecurity' module or the one you shared works fine too.

       

      I used this enable inheritance for 'abc' folder, but it's not enabling inheritance for the child items in the 'abc' holder. The same goes with child items in the parent folder 'C:\Share'. How to enable inheritance for child items too. I want to do this for all the folders that gets created newly on a daily basis.

       

      Thanks in advance.

       

      Get-Item C:\Share\abc\ | Enable-NTFSAccessInheritance

      • farismalaeb's avatar
        farismalaeb
        Steel Contributor

        suren424 

        Regardless,

        The Modules are make to ease and make common tasks easier and possible.

        Have you tried the code I wrote,

        Give it a try on a test folder and see the result, I test it from my side and its working fine, this is a native code, so no need for any module or anything, just copy and paste and thats it.

        Replace the Value or the $Path with any folder and give it a try. if it work (and should) you can add it with a foreach loop. Just try the code on a test folder and post the result back

         

         

Resources