function Get-CurrentUserRoles {

 

$SecurityPrinciple = New-Object -TypeName System.Security.Principal.WindowsPrincipal -ArgumentList ([System.Security.Principal.WindowsIdentity]::GetCurrent())

 

$RolesHash = @{}

 

[System.Enum]::GetNames("¡ãSystem.Security.Principal.WindowsBuiltInRole"¡À) | ForEach-Object {

 

$RolesHash[$_] =

$SecurityPrinciple.IsInRole([System.Security.Principal.WindowsBuiltInRole]::$_)

 

}

 

$RolesHash

 

}

 

Get-CurrentUserRoles

posted on 2017-09-20 10:24  今夜太冷  阅读(735)  评论(0)    收藏  举报