Launch batch code based on AD member of group

Launch the code if a user is part of AD group, for example, the user is a member to group "Awesome":
setlocal EnableDelayedExpansion

reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v ProductName | find "Windows XP" > nul 2>&1
if !errorlevel!==0 (
gpresult /user DOMAIN-COM\%username% | find "Awesome"
if !errorlevel!==0 (

)
)

reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v ProductName | find "Windows XP" > nul 2>&1
if not !errorlevel!==0 (
gpresult /R /user DOMAIN-COM\%username% | find "Awesome"
if !errorlevel!==0 (

)
)

endlocal
gpresult works without /R on windows xp, but on earlier version of windows it do not work if /R is not added to command.

No comments: