/build/static/layout/Breadcrumb_cap_w.png

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)



0 Comments   [ + ] Show comments

Answers (2)

Posted by: barchetta 1 year ago
4th Degree Black Belt
0

What happens if you run this manually in powershell on a device?

IE remove Kace from the equation.

Posted by: jbrower@sanmarcostx.gov 1 year ago
Senior White Belt
0

The solution, weirdly, was making the permission aspect a function. Once I did this it worked perfectly.

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ