Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2107
  • Last Modified:

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","FullControl","Allow"
$accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule $permission
$acl.SetAccessRule($accessRule)
$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
0
thaapavuori
Asked:
thaapavuori
  • 2
1 Solution
 
Bryan ButlerCommented:
Maybe try specifying explicitly:

$permission = $accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule ("users","FullControl","Allow")

Also, in your script, where is $user set?
0
 
Bryan ButlerCommented:
I meant:

$accessRule =
New-Object System.Security.AccessControl.FileSystemAccessRule("users","FullControl","Allow")

0
 
thaapavuoriAuthor Commented:
Thanks this was woking. I was still able to use $user variable. This $user has been typed before by end user.
0

Featured Post

Free recovery tool for Microsoft Active Directory

Veeam Explorer for Microsoft Active Directory provides fast and reliable object-level recovery for Active Directory from a single-pass, agentless backup or storage snapshot — without the need to restore an entire virtual machine or use third-party tools.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now