【发布时间】:2014-03-11 17:06:21
【问题描述】:
这个问题的灵感来自 this similar question 使用 C# 标记。如果我有一个 Windows SID,并且想将其转换为可读的帐户名称,如何使用 PowerShell 而不是 C# 来实现这一点?
现在,我有以下代码,用于检索当前登录用户帐户的组成员身份:
$Identity = [System.Security.Principal.WindowsIdentity]::GetCurrent();
$Identity.Groups;
Groups 属性的结果没有给我任何帐户名称,只有 SID。如果我将Groups 属性的输出通过管道传输到PowerShell 的Get-Member cmdlet,我可以看到生成的对象是System.Security.Principal.SecurityIdentifier 对象。但是,查看 the documentation(和 Intellisense)的 Groups 属性表明它正在返回一个 IdentityReferenceCollection 对象。
如何将这些SecurityIdentifier 对象转换为专有名称?
【问题讨论】:
标签: .net security powershell