JSI Tip 7377. What users are specifically configured to use a specified workstation?

using DSQUERY, I have scripted WhoWorkstation.bat to report on all users who are specifically configured to use a workstation.

The syntax for using WhoWorkstation.bat is:

WhoWorkstation ComputerName \[/C\]

where ComputerName is the NetBIOS name of a computer in your domain, or * for all users who have one or more specific workstations configured, and /C is an optional parameter that will also display the report on the console.

NOTE: WhoWorkstation.bat creates a WhoWorkstation.txt report file in the current folder.

WhoWorkstation.bat contains:

@echo off
if \{%1\}

\{\} @echo Syntax: WhoWorkstation ComputerName \[/c\]&goto :EOF setlocal set comp=%1 set comp=%comp:"=% set console=%2 if exist WhoWorkstation.txt del /q WhoWorkstation.txt if exist %temp%\WhoWorkstation.tm1 del /q %temp%\WhoWorkstation.tm1 set title=N set dsq=dsquery * domainroot -filter "(&(objectCategory=Person)(objectClass=User))" -attr sAMAccountName distinguishedName userWorkstations -limit 999999 for /f "Tokens=*" %%u in ('%dsq%') do set line=%%u&call :out sort %temp%\WhoWorkstation.tm1 /o %temp%\WhoWorkstation.tm2 @echo %title%>WhoWorkstation.txt if /i \{%console%\}

\{/c\} @echo %title% for /f "Tokens=*" %%u in ('type %temp%\WhoWorkstation.tm2') do set line=%%u&call :report if exist %temp%\WhoWorkstation.tm1 del /q %temp%\WhoWorkstation.tm1 if exist %temp%\WhoWorkstation.tm2 del /q %temp%\WhoWorkstation.tm2 endlocal goto :EOF :out if "%title%" EQU "N" set title=%line%&goto where if "%comp%" EQU "*" goto ALL call set wrk=%%line:%comp%=%% if "%line%" EQU "%wrk%" goto :EOF @echo %line%>>%temp%\WhoWorkstation.tm1 goto :EOF :where if "%comp%" NEQ "*" goto :EOF set /a cnt=30 :where1 set /a cnt=%cnt% + 1 call set wrk=%%title:~%cnt%^,16%% if /i "%wrk%" NEQ "userWorkstations" goto where1 goto :EOF :ALL call set wrk=%%line:~%cnt%^,1%% if "%wrk%" EQU " " goto :EOF @echo %line%>>%temp%\WhoWorkstation.tm1 goto :EOF :report if /i \{%console%\}==\{/c\} @echo %line% @echo %line%>>WhoWorkstation.txt

Hide 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.