Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for getid.bat

(view source code of getid.bat as plain text)

  1. @ECHO OFF
  2. :: Check Windows version
  3. IF NOT "%OS%"=="Windows_NT" GOTO Syntax
  4. VER | FIND "[5.2" >NUL
  5. IF ERRORLEVEL 1 GOTO Syntax
  6.  
  7. :: Check number of command line arguments
  8. IF     "%~1"=="" GOTO Syntax
  9. IF NOT "%~2"=="" GOTO Syntax
  10.  
  11. :: Check for invalid command line arguments
  12. ECHO.%* 2>&1 | FIND "/" >NUL
  13. IF NOT ERRORLEVEL 1 GOTO Syntax
  14. ECHO %* 2>&1 | FIND "[" >NUL
  15. IF NOT ERRORLEVEL 1 GOTO Syntax
  16.  
  17. :: Display result
  18. ECHO.
  19. DSQUERY User -name "%~1" | DSGET User -display -samid | FIND /V "" | FIND /V "succeeded"
  20. GOTO:EOF
  21.  
  22. :Syntax
  23. ECHO.
  24. ECHO GetID.bat,  Version 1.02 for Windows Server 2003
  25. ECHO Search and display login and full names based on part of a user's full name
  26. ECHO.
  27. ECHO Usage:    GETID  user_name
  28. ECHO.
  29. ECHO Where:    user_name  is a user's full name, or part of it with wildcards;
  30. ECHO                      use quotes if the search string contains spaces.
  31. ECHO.
  32. ECHO Note:     May fail on user accounts migrated from Windows NT 4.
  33. ECHO.
  34. ECHO Example:  GETID *peter*
  35. ECHO.
  36. ECHO   samid        display
  37. ECHO   WJPET03      Bill Peterson
  38. ECHO   PANDR24      Peter Andrews
  39. ECHO.
  40. ECHO Written by Rob van der Woude
  41. ECHO http://www.robvanderwoude.com
  42.  

page last modified: 2024-04-16; loaded in 0.0073 seconds