Archive for October, 2013

Posted by keith.wirch at October 28, 2013

Category: Batch, Scripts

So we inherited this system from a department at work.  The department got downsized and all documentation was GONE!  When I say gone…. I mean there people are gone and everything that was documented for it.  We got no logins, no IP addresses, nothing.  It was a VMware environment so the benefits of physical server hacking was gone.

After a while we finally were able to get administrative access.  This was some wizardry by one of the other admins.  My part was discover what was on the network.  Network Discovery was turned off for security reasons.  So I used a hacking technique called a Ping Sweep .  This ping sweep allows us to fill our ARP table on the computer and see which computers responded to the arp request.  I’m not a fan of installing random software on servers and workstations so I wanted a script.  So my friend Brian and I got to work on this script.  Batch scripting is not typically my favorite but it works decently well.

@echo off
@color 0A
echo *********************
echo *********************
for /l %%a in (0,1,255) do (
 for /l %%b in (1,1,255) do (
 start ping -n 1 192.168.%%a.%%b | find "Reply"
  echo 192.168.%%a.%%b

REM Used to break up ping so not to overload the workstation.
REM This is curently used for the 3rd octect in the IP Address. Change the variable or the number to change increments.

IF %%a EQU 5 pause
IF %%a EQU 10 pause
IF %%a EQU 15 pause
IF %%a EQU 20 pause
IF %%a EQU 25 pause
IF %%a EQU 30 pause
IF %%a EQU 35 pause
IF %%a EQU 40 pause
IF %%a EQU 45 pause
IF %%a EQU 50 pause
IF %%a EQU 55 pause
IF %%a EQU 60 pause
IF %%a EQU 65 pause
IF %%a EQU 70 pause
IF %%a EQU 75 pause
IF %%a EQU 80 pause
IF %%a EQU 85 pause
IF %%a EQU 90 pause
IF %%a EQU 95 pause

IF %%a EQU 100 pause
IF %%a EQU 105 pause
IF %%a EQU 110 pause
IF %%a EQU 115 pause
IF %%a EQU 120 pause
IF %%a EQU 125 pause
IF %%a EQU 130 pause
IF %%a EQU 135 pause
IF %%a EQU 140 pause
IF %%a EQU 145 pause
IF %%a EQU 150 pause
IF %%a EQU 155 pause
IF %%a EQU 160 pause
IF %%a EQU 165 pause
IF %%a EQU 170 pause
IF %%a EQU 175 pause
IF %%a EQU 180 pause
IF %%a EQU 185 pause
IF %%a EQU 190 pause
IF %%a EQU 195 pause

IF %%a EQU 200 pause
IF %%a EQU 205 pause
IF %%a EQU 210 pause
IF %%a EQU 215 pause
IF %%a EQU 220 pause
IF %%a EQU 225 pause
IF %%a EQU 230 pause
IF %%a EQU 235 pause
IF %%a EQU 240 pause
IF %%a EQU 245 pause
IF %%a EQU 250 pause
IF %%a EQU 255 pause

So because I like color in my scritps, Line 3 allows you to pick your color. I like Green. Enjoy!

The script will open multiple command windows with the sole purpose of running a Ping command.  You can remove the “start” command from line 11 and it will only ping one at a time.  This will be very slow but you will bog down the workstation so much.

Which brings me to the last part of the script.  (Lines 18-70)

This script is VERY processor instensive by default.  Do not try to do anything else while this script is running.  It will slow everything to a crawl.

This is why the last part of the script exists.  Those IF states cause the script to hault waiting for you to continue.  This allows the worksation to have a stopping point to catch up.If these are not there the scipt will just constantly run and run until you have just ping all ranges in the Class B address.  Don’t kill your workstation.  Just modify the IF statements to fit your liking.

Line 11 is where you designate the first two octets of your class B.  This can be configured to a class C easily if you understand variables.  Comment if you need help doing that.

Posted by keith.wirch at October 16, 2013

Category: Powershell, Uncategorized

I find VBScript to be buggy and doesn’t flow very well for me.  I’m still decent at it but Powershell has been my scripting language of choice for a while.  Here is another little diddy I made out of Powershell.

I present to you…. File Delete!  Yea it’s a common thing you do I know but darn it, I don’t like using the admin share all the time to delete files off hundreds of computers.  I execute this script… kick back… watch the beauty of the text scroll up my screen and watch for any errors and investigate.  All while the user is using the computer and they never know!  Makes me feel like some sort of wizard… or ninja….

Ok, grown up time Keith.

So the script is similar to the rest.  Change the last line to your computers.txt file path.

Line 4 is then the file path you want to delete on your remote computer.  This script takes advantages of UNC paths for windows so when you enter this part in, just think of it as you would for a standard admin share.  Remember you will need access to the file location.  Powershell will use the credentials that was opened with your Powershell or Powershell ISE window.

Because I am also experimenting with using Log files, you’ll also need to make an area for the log file for this script.  Or you can delete that area.  I’m starting to like log file though in my scripts.

 function delete-remotefile {
           $file = "\\$_\c$\path\deleted\folder\or\items"
           if (test-path $file)
           echo "$_ File Exists"
           Remove-Item $file -force
           echo "$_ Files deleted"

 # Reads list and pipes to function
 Get-Content C:\Scripts\FileDelete\Computers.txt | delete-remotefile >> C:\Scripts\FileDelete\Log.txt

Posted by keith.wirch at October 15, 2013

Category: Powershell

Small one but a good one.  This script will ping all hosts in a text file to see if they are up.  It’s great in the of case you want to see all of the stations in a classroom before you push an update or something.

Here it is.

$names = Get-Content "C:\Scripts\Computers.txt"

foreach ($name in $names) {

if ( Test-Connection -ComputerName $name -Count 1 -ErrorAction SilentlyContinue ) {

Write-Host "$name is up" -ForegroundColor Magenta


else {

Write-Host "$name is down" -ForegroundColor Red



Line 1 is where you designate your text file of computers.  From there you just execute the powershell script and it will run something like the output below.  I’d reccomend making a bunch of “computer” files for each room you will routinly check like this and then only changeing line 1 to match what you need.

Again, some areas are blurred to protect the innocent!  MSPaint for the win my friends!



Posted by keith.wirch at October 15, 2013

Category: Personal

ccna_certifiedIf you get the networking joke in the title, laugh a little.  I thought I was clever.

But I got my CCNA a while ago.  Loved it.  ICND-1 was a cinch but INCD-2 had me worried though the exam but I passed both with flying colors.  WAN technologies had me worried and I still have a little trouble with MPLS but I think it is similar to Frame-Relay but Frame-Relay is static whereas MPLS is more dynamic.  If anyone reads this let me know if you have questions about CCNA.  I’d love to talk about it.  Unfortunately I don’t get a lot of poeple to talk about it with.  The CCNA track was a ton of fun with the home labs and Jeremy from CBTNuggets was awesome.  Odom’s bookwas great too.

But now I am on to bigger things.  I debated a lot wether to follow another CCNA track like Security, Wireless, or Voice but I kept reading about folks who got to those after you got to CCNP.  I can understand that.  Where I live I doubt I’ll need much past CCNP but the dream of day being CCIE is something I’ll just toy with for now.  The job market around here isn’t great for IT.  A lot people think I should move but my wife and I are very involved in the church we goto and really like staying there.

To study the CCNP track I’m going with the Route Exam fist.  Using Jeremy from CBTNuggets and Diane Teare’s Cisco Press book at the moment.  I like the idea of going with the CCNP Routing and Switching Track so far.  It’s a ton of fun and make soooooo much more sense to me than the MCITP track I followed with Microsoft.

Not to knock against Microsoft but a lot of how to the application works in the background (Like DFS Replication) is unknown!  I know how to set it up, but I’d really like to know how it knows when files match!  Does it use checksums?  I hate that grey area of understanding IT.  With Cisco and networking I can totally understand the logic of everything I work with.  How does dot1q work?  Well the switch adds the vlan tag in the layer 2 header of an IP packet so that the switch at the other end of trunk link know what VLAN it is for!  It’s a 4 byte tag!  I know that information down to that level!

Anyway.  Really excited for CCNP.  I’ll likely post things about what I learn on here.  A lot of the material is likely gonna be new so I’m quite excited to jump in.

For those who didn’t get the joke.  In a Cisco, there is to states for an Ethernet (Or Serial) Interface; Link Status and Protocol Status.  If you have Up and Up that means the cable is connected and the Line Protocol is up and everything should be working.  So CCNA Up and Up means I have started and understand the content.  An Up and Down in networking is where the cable is plugged in but the Line Protocol is Down.  This means I have started the process but don’t completely understand the content.