raandree / NTFSSecurity

Managing permissions with PowerShell is only a bit easier than in VBS or the command line as there are no cmdlets for most day-to-day tasks like getting a permission report or adding permission to an item. PowerShell only offers Get-Acl and Set-Acl but everything in between getting and setting the ACL is missing. This module closes the gap.
MIT License
431 stars 61 forks source link

Recurse parameter for Set-NTFSOwner #7

Closed riahc3 closed 7 years ago

riahc3 commented 8 years ago

Im kind of surprised why Set-NTFSOwner does not have a Recurse parameter.

raandree commented 8 years ago

There was a recurse parameter quite long ago. There was some trouble with that but I must confess, I do not remember the technical details.

Is that a workaround?

dir -Recurse | Set-NTFSOwner -Account SYSTEM

riahc3 commented 8 years ago

Ill give it a shot tomorrow at work.

Please implement it. If you need help, there is some code and discussion already here: https://learn-powershell.net/2014/06/24/changing-ownership-of-file-or-folder-using-powershell/

It doesnt work correctly for me as that doesnt pass the 260 path limit.

Thank you for reading and replying.

riahc3 commented 8 years ago

Nope, same error when reaching a 260 limit.

$Folder="D:\somefolder\anotherfolder"

dir $Folder -Recurse | Set-NTFSOwner -Account 'mysuernameindomain'
raandree commented 8 years ago

Can you just replace the command 'dir' with 'dir2', then it works without the path limitation.

dir2 -Recurse | Set-NTFSOwner -Account install

There are some other commands for working around the path limitation provided by this module. Try:

Get-Command -Module NTFSSecurity -Name *Item2