Skip to content

Instantly share code, notes, and snippets.

@dezfowler
Created May 18, 2022 15:33
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 dezfowler/bea848d04631be14c90943aa4428a6c0 to your computer and use it in GitHub Desktop.
Save dezfowler/bea848d04631be14c90943aa4428a6c0 to your computer and use it in GitHub Desktop.
Fix incorrect file or folder owner
param (
[string]$from = $(throw "-from is required."),
[string]$to = $(throw "-to is required.")
)
$correctOwner = (Get-Acl $from).GetOwner([System.Security.Principal.SecurityIdentifier])
$acl = Get-Acl $to
$acl.SetOwner($correctOwner)
Set-Acl $to $acl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment