Skip to content

Instantly share code, notes, and snippets.

@gojimmypi
Created January 17, 2021 21:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gojimmypi/4ebce7c3072ec9942d8fa79f9bab9015 to your computer and use it in GitHub Desktop.
Save gojimmypi/4ebce7c3072ec9942d8fa79f9bab9015 to your computer and use it in GitHub Desktop.
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