The computer enumeration of the new domain displays the batch processing of the domain adding 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.

Copy codeThe Code is as follows: @ 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
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.