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

Jerold Schulman

October 26, 2003

1 Min Read
ITPro Today logo in a gray background | ITPro Today


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 offif {%1}
{} @echo Syntax: WhoWorkstation ComputerName [/c]&goto :EOFsetlocalset comp=%1set comp=%comp:"=%set console=%2if exist WhoWorkstation.txt del /q WhoWorkstation.txtif exist %temp%WhoWorkstation.tm1 del /q %temp%WhoWorkstation.tm1set title=Nset dsq=dsquery * domainroot -filter "(&(objectCategory=Person)(objectClass=User))" -attr sAMAccountName distinguishedName userWorkstations -limit 999999for /f "Tokens=*" %%u in ('%dsq%') do set line=%%u&call :outsort %temp%WhoWorkstation.tm1 /o %temp%WhoWorkstation.tm2@echo %title%>WhoWorkstation.txtif /i {%console%}
{/c} @echo %title%for /f "Tokens=*" %%u in ('type %temp%WhoWorkstation.tm2') do set line=%%u&call :reportif exist %temp%WhoWorkstation.tm1 del /q %temp%WhoWorkstation.tm1if exist %temp%WhoWorkstation.tm2 del /q %temp%WhoWorkstation.tm2endlocalgoto :EOF:outif "%title%" EQU "N" set title=%line%&goto whereif "%comp%" EQU "*" goto ALLcall set wrk=%%line:%comp%=%%if "%line%" EQU "%wrk%" goto :EOF@echo %line%>>%temp%WhoWorkstation.tm1goto :EOF:whereif "%comp%" NEQ "*" goto :EOFset /a cnt=30:where1set /a cnt=%cnt% + 1call set wrk=%%title:~%cnt%^,16%%if /i "%wrk%" NEQ "userWorkstations" goto where1goto :EOF:ALLcall set wrk=%%line:~%cnt%^,1%%if "%wrk%" EQU " " goto :EOF@echo %line%>>%temp%WhoWorkstation.tm1goto :EOF:reportif /i {%console%}=={/c} @echo %line%@echo %line%>>WhoWorkstation.txt



Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like