0

I am currently adding Full control to an user manually. Please see below screen shot. But this needs to be done via a PS script.I followed https://blogs.technet.microsoft.com/heyscriptingguy/2010/11/18/use-powershell-to-set-security-permissions-for-remoting/ link but I am getting an error while executing this one by one. Please suggest.

Error-

PS C:\Windows\system32> $user = "bsg\sisyphus"
PS C:\Windows\system32> $accval = New-Object Security.Principal.NTAccount $user
PS C:\Windows\system32> $accval

Value
-----
bsg\sisyphus


PS C:\Windows\system32> $sid = $accval.Translate([Security.Principal.SecurityIdentifier]).Value
Exception calling "Translate" with "1" argument(s): "Some or all identity references could not be translated."
At line:1 char:1
+ $sid = $accval.Translate([Security.Principal.SecurityIdentifier]).Val ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : IdentityNotMappedException

enter image description here

asur
  • 101
  • 2
  • Are you sure the user name is correct? You can make sure everything is otherwise correct with `(New-Object Security.Principal.NTAccount (whoami)).Translate([Security.Principal.SecurityIdentifier])` – Matthew Wetmore Mar 17 '18 at 04:07

1 Answers1

0

Try renaming Security.Principal.NTAccount to System.Security.Principal.NTAccount and see if you get a different error.

Jay
  • 63
  • 1
  • 2
  • 8