2013-05-14 1 views
1

몇 가지 작업을 수행 한 후 사용자 AD 그룹 구성원을 기준으로 세 가지 응용 프로그램 중 하나를 실행해야하는 powershell 스크립트를 작성하고 있습니다. 나는 AD 모듈을로드 할 수 없습니다, 그래서 나는gpresult/r에 해당하는 광고 모듈이없는 powershell

$temp = gpresult.exe /r 
if ($temp -match "myAdGroup") { ... } 

보다 효율적으로 같은 일을 할 수있는 PowerShell 명령이 있는가 gpresult.exe /r을 사용하고 있습니다?

답변

4

하나의 방법이다 : 그것은 완벽하게 작동

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

if($WindowsPrincipal.IsInRole("myAdGroup")) 
{ 
    ... 
} 
else 
{ 
    ... 
} 
+0

, 감사합니다! – Naigel

관련 문제