Posted On February 16, 2022

PowerShell: Grant Current User Full Access to File or Folder

kimconnect 0 comments
blog.KimConnect.com >> Codes >> 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 *

Related Post

Basic JavaScript: Access Multi-Dimensional Arrays With Indexes

// Setupvar myArray = [[1,2,3], [4,5,6], [7,8,9], [[10,11,12], 13, 14]];// Using bracket notation select an…

PowerShell: Scan a Subnet for Used and Unused IPs

A newer version of this script is available here. function scanForAvailableIPs{ param( $cidrBlock=$( $interfaceIndex=(Get-WmiObject -Class…

PowerShell: Check Whether an Application Is Installed Using Known Service Name

# Check whether product is installed $serviceName='windows_exporter' function checkUninstall($serviceName){ $cpuArchitecture32bitPointerSize=4 $path=if ([IntPtr]::Size -eq $cpuArchitecture32bitPointerSize) {…