![PS-远程 shell 访问用户](https://linux22.com/image/718938/PS-%E8%BF%9C%E7%A8%8B%20shell%20%E8%AE%BF%E9%97%AE%E7%94%A8%E6%88%B7.png)
我目前正在手动向用户添加完全控制权。请参见下面的屏幕截图。但这需要通过 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,看看是否出现不同的错误。