PowerShell: Grant Current User Full Access to File or Folder

# Grant Current User Full Access to Object
$object='C:\temp'
$acl=Get-Acl $object
$currentUser=[System.Security.Principal.WindowsIdentity]::GetCurrent().Name
$grantAccess=New-Object System.Security.AccessControl.FileSystemAccessRule("$currentUser","FullControl","Allow")
$acl.AddAccessRule($grantAccess)
Set-Acl $object $acl

Leave a Reply

Your email address will not be published. Required fields are marked *