I am having this below code where I am trying to remove and then provide Modify and write access to the Authenticated User for D:\ drive
$systemDrives = Get-PSDrive -PSProvider FileSystem | where {($_.Name -eq "D")}
foreach($driveLetter in $systemDrives)
{
$path = $driveLetter.Root
icacls $path /remove "Authenticated Users"
icacls $path /grant "Authenticated Users:M,W"
}
the /remove
part is removing the authenticated user from the drive but when I am doing /grant
, it is creating the user back but not assigning the permissions.
Please let me know what I am missing here