thaapavuori
asked on
Trying to set ACL via PowerShell to UNC path
I'm trying to set ACL via powershell. My script is here:
$acl = Get-Acl $folder
$permission = "domain\$user","FullContro l","Allow"
$accessRule = New-Object System.Security.AccessCont rol.FileSy stemAccess Rule $permission
$acl.SetAccessRule($access Rule)
$acl | Set-Acl $folder
This $folder variable content is UNC path.
When I run this script I get error message:
Exception calling "SetAccessRule" with "1" argument(s): "Some or all identity references could not be translated."
At C:\temp\FTPUser.ps1:50 char:19
+ $acl.SetAccessRule <<<< ($accessRule)
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
What I have done incorrectly?
Thanks
$acl = Get-Acl $folder
$permission = "domain\$user","FullContro
$accessRule = New-Object System.Security.AccessCont
$acl.SetAccessRule($access
$acl | Set-Acl $folder
This $folder variable content is UNC path.
When I run this script I get error message:
Exception calling "SetAccessRule" with "1" argument(s): "Some or all identity references could not be translated."
At C:\temp\FTPUser.ps1:50 char:19
+ $acl.SetAccessRule <<<< ($accessRule)
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
What I have done incorrectly?
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks this was woking. I was still able to use $user variable. This $user has been typed before by end user.
$permission = $accessRule = New-Object System.Security.AccessCont
Also, in your script, where is $user set?