更新时间:2022-06-12 08:32:47
解决方案是使用 SecurityIdentifier
类。此方法的单个参数是对您要将 SecurityIdentifier
转换为.NET类型的引用。如果检查类似的C#问题的此答案,您会发现您可以简单地传递对 System.Security.Principal。 NTAccount类。
The solution is to use the Translate()
method of the SecurityIdentifier
class. The single parameter for this method is a reference to the .NET type that you would like to convert the SecurityIdentifier
to. If you examine this answer to the similar C# question, you will see that you can simply pass in a reference to the System.Security.Principal.NTAccount class.
结果代码如下:
$Identity = [System.Security.Principal.WindowsIdentity]::GetCurrent();
foreach ($Group in $Identity.Groups) {
$Group.Translate([System.Security.Principal.NTAccount]).Value;
}