Computer enumeration of the new domain, showing batch processing for _dos/bat

Source: Internet
Author: User
Tags goto dsquery
FileName: Querycomputer.bat

Features: Finds computers that are not grouped within a domain and displays the computer name and user with domain

Role: You can implement a list of monitoring computers to remind computer groupings, but also to audit the computer naming norms, determine the responsible person.

Note: Before a batch is run, it is a good idea to group all computers in the computers container within an existing domain by an OU, and the script will list the new computers in the Computers container after it runs.

Copy Code code as follows:

@echo off
No grouped computer monitoring in echo domain
echo If you find a computer, it displays a list of the computers found and prompts you with a PC horn.
Echo.
CD/D%~dp0
REM Setting NetBIOS domain name
Set Domain=domainname
REM Set domain name
Set Dc=mydomain
Set dc1=com
: Loop
Set Found=0
REM Search for Vegetarian comouters
for/f%%i in (' dsquery computer cn^=computers^,dc^=%dc%^,dc^=%dc1% ') do set found=1
rem If you find a computer, call the display module
If%found%==1 call:d isplay
Ping-n 127.0.0.1 >nul 2>&1
Goto Loop
Goto:eof
:d Isplay
echo%date%%time% found following computers:
REM reads the computer ad path and invokes 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%.%d C1%/%dsname: "=%
REM Get computer name
for/f "tokens=2,3* delims=,="%%i in (' echo%dsname% ') do set name=%%i
REM Displays computer permissions and displays permissions to set DNS information for users (plus domain), dscals need to install support Tools
DSACLS%dsname1% |find "%domain%" |find "DNS" >name.txt
for/f "tokens=1,2,3*"%%i in (name.txt) do set user=%%j
Echo%name%,%user%
REM Record information
echo%name%,%user%>> "%date%.csv"
rem beep Alarm, beep write yourself or go online to find
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.