Add permission Script No Longer Working
I have a script that would copy a folder, rename the new folder and then add the proper permissions to the new folder. This script worked flawlessly for a year then all of a sudden it stopped adding the permissions. I keep getting
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : IdentityNotMappedException
I am including the script below, Any help will be greatly appreciated
$NewUser = Read-Host "Enter Name"
Copy-Item \\ComputerName\Profiles\Template \\ComputerName\Profiles\$NewUser -Recurse
$identity = "Domain\$NewUser"
$rights = 'FullControl'
$inheritance = 'ContainerInherit, ObjectInherit'
$propagation = 'None'
$type = 'Allow'
$ACE = New-Object System.Security.AccessControl.FileSystemAccessRule($identity,$rights,$inheritance,$propagation,$type)
$ACL = Get-Acl -Path "\\ComputerName\Profiles\$NewUser"
$ACL.AddAccessRule($ACE)