PS-远程 shell 访问用户

PS-远程 shell 访问用户

我目前正在手动向用户添加完全控制权。请参见下面的屏幕截图。但这需要通过 PS 脚本完成。我遵循https://blogs.technet.microsoft.com/heyscriptingguy/2010/11/18/use-powershell-to-set-security-permissions-for-remoting/链接,但我在逐个执行时收到错误。请提出建议。

错误-

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

在此处输入图片描述

答案1

尝试将 Security.Principal.NTAccount 重命名为 System.Security.Principal.NTAccount,看看是否出现不同的错误。

相关内容