Skip to content

Instantly share code, notes, and snippets.

@gojimmypi

gojimmypi/wchown.bat

Created Jan 17, 2021
Embed
What would you like to do?
Take ownership and assign permissions in Windows
takeown /f "c:\files" /r
:: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.security/set-acl?view=powershell-7.1
::
:: get permissions from a sample file
$NewAcl = Get-Acl File0.txt
:: apply those permissions to other files
Get-ChildItem -Path "C:\files" -Recurse -Include "*.txt" -Force | Set-Acl -AclObject $NewAcl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment