Hello.
Anyone know if its possible to get the membership/group that a user belongs
to in a logon script?
Thanks in advance
setlocal enabledelayedexpansion
for /f "Tokens=1-3 Delims=*" %%a in ('net user %username% /domain^|Find " *"') do (
set g1=%%a
set g2=%%b
set g3=%%c
...
....
....
)
or
Use ADFind.exe, tip 5898 » Freeware ADFind.
in the 'Tips & Tricks' at
http://www.jsifaq.com
Place Adfind.exe in the Netlogon share of all DCs.
@echo off
setlocal
for /f "Tokens=*" %%g in ('%LOGONSERVER%\NETLOGON\adfind.exe -nodn -csv -nocsvheader -default -f "&(objectcategory=person)(objectClass=user)(sAMAccountName=%UserName%)" memberOf') do (
if %%g NEQ "" call :groups %%g
)
endlocal
goto :EOF
:groups
set gline=%1
set gline=%gline:"=%
....
....
....
Jerold Schulman
Windows Server MVP
JSI, Inc.
http://www.jsiinc.com
http://www.jsifaq.com