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.
- @ Echo off
- Ungrouped computers in the ECHO domain Monitor
- Echo if a computer is found, a list of computers is displayed, and a prompt is displayed through the PC speaker.
- Echo.
- CD/d % ~ Dp0
- Rem sets NetBIOS Domain Name
- Set domain = domainname
- Rem set Domain Name
- Set Dc = mydomain
- Set DC1 = com
- : Loop
- Set found = 0
- Rem search comouters
- For/F % I in ('dsquery computer CN ^ = computers ^, DC ^ = % DC % ^, DC ^ = % DC1 % ') do set found = 1
- Rem calls the display module if a computer is found.
- If % found % = 1 call: Display
- Ping-N 600 127.0.0.1> NUL 2> & 1
- Goto Loop
- Goto: EOF
- : Display
- Echo % date % time % found following computers:
- Rem reads the computer's ad path and calls the display information module
- For/F % I in ('dsquery computer CN ^ = computers ^, DC ^ = % DC % ^, DC ^ = % DC1 % ') Do call: info % I
- Goto: EOF
- : Info
- Set dsname = % 1
- Set dsname1 = // % DC %. % DC1 %/% dsname: "= %
- Rem obtains the computer name
- For/F "tokens = 2, 3 * delims =, =" % I in ('echo % dsname % ') do set name = % I
- Rem displays the computer permissions and the users who can set DNS information (persons with Domain Names). dscals needs to install Support Tools
- Dsacls % dsname1 % | find "% domain %" | find "DNS"> name.txt 2> & 1
- For/F "tokens = 1, 2, 3 *" % I in (name.txt) do set user = % J
- Echo % name %, % USER %
- Rem record information
- Echo % name %, % USER %> "paidate0000.csv"
- Rem beep alert, which is written by beep or found on the Internet
- Echo.
- Beep 1500 500
- Beep 500 500
- Beep 1500 500
- Beep 500 500
- Beep 1500 500
- Beep 500 500
- Beep 1500 500
- Beep 500 500
- Goto: EOF