[Batch processing application] Computer enumeration of new domains, displaying domain-added personnel

Source: Internet
Author: User
Tags dsquery
File Name: querycomputer. bat
Function: finds ungrouped computers in the domain and displays the computer name and users in the domain.
Purpose: monitor the computer list to remind you to group computers. You can also check whether the computer naming rules are correct and determine the owner.
Note: Before batch processing, you are advised to group all the computers in the computers container in the existing domain by OU. After the script is run, the new computers in the computers container will be listed.
  1. @ Echo off
  2. Ungrouped computers in the ECHO domain Monitor
  3. Echo if a computer is found, a list of computers is displayed, and a prompt is displayed through the PC speaker.
  4. Echo.
  5. CD/d % ~ Dp0
  6. Rem sets NetBIOS Domain Name
  7. Set domain = domainname
  8. Rem set Domain Name
  9. Set Dc = mydomain
  10. Set DC1 = com

  11. : Loop
  12. Set found = 0

  13. Rem search comouters
  14. For/F % I in ('dsquery computer CN ^ = computers ^, DC ^ = % DC % ^, DC ^ = % DC1 % ') do set found = 1
  15. Rem calls the display module if a computer is found.
  16. If % found % = 1 call: Display
  17. Ping-N 600 127.0.0.1> NUL 2> & 1
  18. Goto Loop
  19. Goto: EOF

  20. : Display
  21. Echo % date % time % found following computers:
  22. Rem reads the computer's ad path and calls the display information module
  23. For/F % I in ('dsquery computer CN ^ = computers ^, DC ^ = % DC % ^, DC ^ = % DC1 % ') Do call: info % I
  24. Goto: EOF
  25. : Info
  26. Set dsname = % 1
  27. Set dsname1 = // % DC %. % DC1 %/% dsname: "= %
  28. Rem obtains the computer name
  29. For/F "tokens = 2, 3 * delims =, =" % I in ('echo % dsname % ') do set name = % I
  30. Rem displays the computer permissions and the users who can set DNS information (persons with Domain Names). dscals needs to install Support Tools
  31. Dsacls % dsname1 % | find "% domain %" | find "DNS"> name.txt 2> & 1
  32. For/F "tokens = 1, 2, 3 *" % I in (name.txt) do set user = % J
  33. Echo % name %, % USER %
  34. Rem record information
  35. Echo % name %, % USER %> "paidate0000.csv"
  36. Rem beep alert, which is written by beep or found on the Internet
  37. Echo.
  38. Beep 1500 500
  39. Beep 500 500
  40. Beep 1500 500
  41. Beep 500 500
  42. Beep 1500 500
  43. Beep 500 500
  44. Beep 1500 500
  45. Beep 500 500
  46. Goto: EOF

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.