| A command to take charge of a windows directory, children, and subfolders |
2026-10-02
|
|
|
[command]
[windows]
[ownership]
[permissions]
|
|
|
if(!(whoami /groups|sls S-1-16-12288)){'Need Admin';break};$p='C:\Users\sschiavone';$m=Get-WindowsImage -Mounted|?{$_.Path -eq $p};if($m -and "$($m.MountStatus)" -ne 'Ok'){"MOUNT $($m.MountStatus) - dism /Unmount-Image /MountDir:$p /Discard; dism /Cleanup-Mountpoints";break};$A='*S-1-5-32-544';takeown /f $p /r /d y /a /skipsl|?{$_-match'denied|Error'};icacls $p /setowner $A /t /l /c /q;icacls $p /reset /t /l /c /q;icacls $p /grant "${A}:(OI)(CI)F" /t /l /c /q;'owned'
|
|
|