Forum Discussion
Powershell script to enable inheritance for the folders created in NTFS share
- Sep 30, 2020
You can use this example
$x=Get-ItemProperty -Path C:\MyFolder\123\456 Write-Host "The Parent is " -ForegroundColor Green -NoNewline $x.Parent.Nameif the answer fulfill your needs, please don't forget to click on Best Response and give a like 🙂
Thanks
You can use this example
$x=Get-ItemProperty -Path C:\MyFolder\123\456
Write-Host "The Parent is " -ForegroundColor Green -NoNewline
$x.Parent.Nameif the answer fulfill your needs, please don't forget to click on Best Response and give a like 🙂
Thanks
Thank youfarismalaeb
It worked. Can i print what permissions is this script setting and what were there on the child folder before ?
And does this below script looks fine or am i missing anything?
I am trying to get the parent folder for the child item and inherit the permissions. Just wanted to make sure, i am not redoing the same thing as it is in the for loop.
Script :
$the_shares = ('C:\OIMShare\abc\', 'C:\OIMShare\abc1\','C:\OIMShare1\def\','C:\OIMShare2\ghi\')
$allFolders=Get-ItemProperty -Path $the_shares
Write-Host "The Parent is " -ForegroundColor Green -NoNewline
$allFolders.Parent.Name
foreach ($Folder in $allFolders){
$Permission=get-acl -Path $Folder.FullName
$Permission.SetAccessRuleProtection($False,$true)
Set-Acl -Path $Folder.FullName -AclObject $Permission
}
Thanks in advance.