Hi,
You restart a remote server because you installed some new MS updates and you need to know when it's back online.
What we all do?, start pinging the server and continue to do other things.
when we come back after few minutes to the ping window we see that the server is online but we missed to see it's gone offline.
The following script (I called it "Smart Ping") will check the output from the ping action and look for specific word to let you know that the server went down and went up again.
Fill free to change the words it searches as you see fit in your environment.
=======================================
echo off
cls
:dead
title Server [%1] is going to shut down [%time%]...
ping -n 1 -w 300 %1 find "Request timed out."
IF %ERRORLEVEL% == 0 (goto back_alive) ELSE (goto dead)
:back_alive
title Server [%1] is down [%time%]...
ping -n 1 -w 300 %1 find "TTL"
IF %ERRORLEVEL% == 0 (goto end) ELSE (goto back_alive)
:end
title Server [%1] is Back online [%time%]...
pause
=======================================
Enjoy...
Showing posts with label cmd. Show all posts
Showing posts with label cmd. Show all posts
19 May, 2009
10 May, 2009
Get AD group members (including nesting)
I looked for some time now for a command that will give me all the members of a group even if it contains nesting groups.
I'm happy to inform you that the answer was allways under my nose.
The command was: DSGET.
The following syntax worked for me:
==================================
dsget group CN=Group_Name,OU=Groups,DC=domain,DC=local -members -expand
==================================
MS Link
You can mix it up with my tip on how to get the DN from an NT name and simplify the command...
I'm happy to inform you that the answer was allways under my nose.
The command was: DSGET.
The following syntax worked for me:
==================================
dsget group CN=Group_Name,OU=Groups,DC=domain,DC=local -members -expand
==================================
MS Link
You can mix it up with my tip on how to get the DN from an NT name and simplify the command...
01 April, 2009
See which machine is alive...
If you need to run on a list of machines with some command, you want to make sure that the workstations (or servers) are alive and pingble.
The following script allow you to do just that.
It contains 3 elements:
By for now...
The following script allow you to do just that.
It contains 3 elements:
- "computers.txt" - the full list of computers in your LAN (probably from AD), names only!!!
- "Step1.cmd" - run's the next file in a loop on each line from "computers.txt"
- "Step2.cmd" - The command itself.
content of step1.cmd:
======================
for /f %%A in (computers.txt) do (step2.cmd %%A)
======================
content of step2.cmd:
======================
ping -n 1 -w 300 %1 find "TTL">nul
IF %ERRORLEVEL% == 0 (echo %1 >> alive.txt) ELSE (echo %1 >> dead.txt)
======================
By for now...
Subscribe to:
Posts (Atom)