active directory - equivalent of gpresult /r with powershell without ad module -
i'm working on powershell script that, after doing stuffs, should launch 1 of 3 applications based on user ad group membership. can't load ad module, i'm using gpresult.exe /r
$temp = gpresult.exe /r if ($temp -match "myadgroup") { ... }
is there powershell command same thing more efficiently?
one way is:
$currentuser = [system.security.principal.windowsidentity]::getcurrent() $windowsprincipal = new-object system.security.principal.windowsprincipal($currentuser) if($windowsprincipal.isinrole("myadgroup")) { ... } else { ... }
Comments
Post a Comment