Skip navigation

JSI Tip 9856. How can I decode the grouptype attribute?


I have scripted EnumGroupType.bat to return the group scope and group type.

The syntax for using EnumGroupType.bat is:

call EnumGroupType GroupType Scope SecDst

Where:

GroupType is the GroupType attribute of a group.

Scope     is a call directed environment variable that will contain:
                          B   for a Built-in group.
                          L   for a Domain Local group.
                          G   for a Global group.
                          U   for a Universal group.

SecDst   is a call directed environment variable that will contain:
                          S   for a security group.
                          D   for a distribution group.
EnumGroupType.bat contains:
@echo off
if \{%3\}==\{\} @echo Syntax: EnumGroupType GroupType Scope SecDst&goto :EOF
setlocal
if exist "TEMP%\EnumGroupType.vbs" goto start
@echo.Dim objArgs, gt>"%TEMP%\EnumGroupType.vbs"
@echo.Set objArgs = Wscript.Arguments>>"%TEMP%\EnumGroupType.vbs"
@echo.gt = objArgs(0)>>"%TEMP%\EnumGroupType.vbs"
@echo.if (gt ANd ^&h01) ^ 0 then>>"%TEMP%\EnumGroupType.vbs"
@echo. Scope = "B">>"%TEMP%\EnumGroupType.vbs"
@echo.ElseIf (gt And ^&h02) ^ 0 Then>>"%TEMP%\EnumGroupType.vbs"
@echo. Scope = "G">>"%TEMP%\EnumGroupType.vbs"
@echo.ElseIf (gt And ^&h04) ^ 0 Then>>"%TEMP%\EnumGroupType.vbs"
@echo. Scope = "L">>"%TEMP%\EnumGroupType.vbs"
@echo.ElseIf (gt And ^&h08) ^ 0 Then>>"%TEMP%\EnumGroupType.vbs"
@echo. Scope = "U">>"%TEMP%\EnumGroupType.vbs"
@echo.End If>>"%TEMP%\EnumGroupType.vbs"
@echo.If (gt And ^&h80000000) ^ 0 Then>>"%TEMP%\EnumGroupType.vbs"
@echo. SecDst = "S">>"%TEMP%\EnumGroupType.vbs"
@echo.Else>>"%TEMP%\EnumGroupType.vbs"
@echo. SecDst = "D">>"%TEMP%\EnumGroupType.vbs"
@echo.End If>>"%TEMP%\EnumGroupType.vbs"
@echo.Wscript.Echo Scope ^& " " ^& SecDst>>"%TEMP%\EnumGroupType.vbs"
:start
for /f "Tokens=1,2" %%x in ('cscript //nologo "%TEMP%\EnumGroupType.vbs" %1') do (
 set s1=%%x
 set s2=%%y
)
endlocal&set %2=%s1%&set %3=%s2%



Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish