gwmi Win32_TSAccount -namespace root \ cimv2 \ terminalservices r

时间:2017-06-07 19:10:22

标签: powershell

gwmi Win32_TSAccount -namespace root\cimv2\terminalservices

  

以略微格式允许的结果权限。

我们怎样才能转换为reaabale格式?

1 个答案:

答案 0 :(得分:0)

试试这个:

function Get-PermissionStrings {

    param([int]$Bits)

    $Permissions = @{
        0x001 = "WINSTATION_QUERY"
        0x002 = "WINSTATION_SET"
        0x004 = "WINSTATION_LOGOFF"
        0x010 = "WINSTATION_SHADOW"
        0x020 = "WINSTATION_LOGON"
        0x040 = "WINSTATION_RESET"
        0x080 = "WINSTATION_MSG"
        0x100 = "WINSTATION_CONNECT"
        0x200 = "WINSTATION_DISCONNECT"
        0xF0008 = "WINSTATION_VIRTUAL | STANDARD_RIGHTS_REQUIRED"
    }

    foreach($Bitmask in $Permissions.Keys | Sort-Object){
        if(($Bits -band $Bitmask) -eq $Bitmask){
            $Permissions[$Bitmask]
        }
    }
}