Splunk User Group in Lincoln/Omaha Nebraska

I am currently working with Continuum (http://www.continuumww.com) to bring the Lincoln/Omaha area of Nebraska a Splunk user group. I am a big believer in the sharing of knowledge. With that I love to go on to the Splunk Answers site and review issues or questions people have and try to help them. When I was learning IT, someone took the time to answer my questions. I want to give back to the community that has taught me so much. This is where my sports life meets my geek life. I want to be that coach to help others get the most of IT. Look for more information shortly.

Workout Logs

I have been going to the local YMCA over my lunch hour for lifting for the past 6 months.  I am starting to feel good again.  I have even started taking some supplements to help me feel even better.  A big shout out to the guys at Max Muscle for getting me the right supplements.  It is so nice to be able to go in to a shop that you would think is just full of meat heads and to hear exactly what each thing you are taking does to your body and how they react with each other.  In the past I have gone places and got the you need this as they plop containers of stuff in front of me and expect you to shell out money.  I have even had them tell me not to take something as they didn’t think I would get the results I wanted from it.  While I am not a small guy, I am not the biggest guy either.  I stand a whole 5′ 10″. I am not a runner so my idea of cardo is walking to the gym.  I like to lift large weights.  I never was the type to just go to the gym to tone out.  One of the programs I most enjoyed with a workout series titled “50lbs in 50 days”.  The goal was pretty simple, to put 50 pounds on your max bench press lift in 50 days. I went from 260lbs to 320lbs.  It wasn’t the easiest workout.  My lifting partner and I went to the gym at least 5 days a week for any where from 1 to 2 hours.

Workout Tracker:
JeFIT (free program to track workouts, design workouts, track body stats, etc.  Used to generate the following reports.)

Supplements:
Max Muscle 2TX
Max Muscle Max Pro Protein
Max Muscle XTINGUISHER
Max Muscle Cleanse AND Lean
Starting Body Stats:

Neck
17.75 inches

Shoulders
50.5 inches

Arms
15.5 inches

Chest
47.5 inches

Waist
45.5 inches

Forearms
12.75 inches

Calves
16 inches

Hips
41 inches

Thighs
26.5 inches

 Lifting Stats as of 09/15/2012:

Progress Chart Barbell Bench Press – 289 lbs

Progress Chart Barbell Tricep Extension – 126 lbs

Progress Chart Barbell Bicep Curl – 126 lbs

Progress Chart Barbell Shoulder Press – 162 lbs

 

 Workout Log from 10/03/2012:

Dumbbell Incline Bench Press
60×8,70×6,75×6
90lb 1RM

Straight Arms Dumbbell Pullover
50×8,50×6,50×6
63lb 1RM

Dumbbell Fly
35×8,35×8,35×6
44lb 1RM

Cable Triceps Pushdown
180×6,192×6,204×6
245lb 1RM

Dumbbell One Arm Triceps Extension
27.5×8,35×6,35×6
42lb 1RM

Dumbbell One Arm Triceps Extension
27.5×6,32.5×6,32.5×6
39lb 1RM

Lawn Mower Start Lift
75×6,72×6,72×6
90lb 1RM

Standing Biceps Cable Curl
80×8,80×8,100×6
120lb 1RM

Lats Only Straight Bar Pull Up
0x6,0x6,0x6
6lb 1RM

What Wrestling Taught Me

In my life I had the opportunity for a lot of great coaches. There has been two that really stand out. The first coach got my going in the right direction. The second coach showed me just how far you can push yourself.

The Early Years:
My first year of wrestling was, well, a true test in perseverance. I don’t remember much of that year except a few thing.

  1. Bringing a book on wrestling moves to practice to teach myself some moves
  2. I cried a lot and my Dad had to convince me to finish out tournaments
  3. I lost every match

The next year my Dad took me to another club, the Lincoln Squires. This is the little kids club that was supposed to feed into the Lincoln Southeast High School program.  What a change.  The practice was structured and the very first night we learned things.  The head coach, Rik Gropp, made it a point to come and talk to me.  He explained how the practice works and introduces me to my drill partner for the day.  After practice Rik came up to me and asked me how I liked practice.  The true test came at the first tournament.  I got to the tournament nervous as in the past.  I haven’t had good luck in the past tournaments. I showed up and one of the coaches saw me.  He walked me to where we weighed in and then walked with me to our team.  I warmed up with the team and then the coach was there for each match.  I can’t remember how I did, but I do remember feeling that some was a lot different.  It felt like someone cared how I did.  I am sure that for my dad is was a relief that I wasn’t dreading matches and that I had some confidence.  Throughout the season I won and lost matches.  At one of the tournaments I walked off the mat happy that I won but I noticed my coach was jumping around and ran up and gave me a hug.  I thought that it was a little over kill for winning a match.  He looked at me and asked how it feels now that I qualified for Huskerland?  I look at him puzzled as I didn’t know what Huskerland was.  Huskerland is the end of year tournament for the top wrestler in the state to see who the best is.  It is equivalent of state in high school sports.  I am not sure how I did the rest of the year, but one thing I do remember is I liked wrestling.  I liked the fact that it was up to me to win or lose.  I couldn’t blame it on someone else missing their block or missing a shot.  Either I won or I lost.  The other thing I liked was the wrestling community was like a family.  I spent the next few years learning a lot of the fundamentals of the sport and being a good sport in winning and losing.  The way Rik coached was to make sure you understand the moves and why to use them.  He made sure that everyone understood that it was about the kids who were wrestling.  Rik and his coaches cared about each and every one of us.  We had a great understand of the sport.  If you won your match, you got a hug or high five and then a coach sat down and explained what you did right and what you need to work on.  It was the same if you lost.  This team was a family with coach Rik acting like another father and the other coaches as your big brothers.

Pushing it to the limit:
Entering high school I was faced with a new set of challenges.  The Lincoln Squires program did not feed in to the Pius X High School program and I had wrestled a few of the people on the team or their brothers.  I was a marked freshmen.  The coach we had was a good coach but wrestling wasn’t his love.  I was “hazed” daily by my teammates.  I remember being pinned to the mat before practice and getting titty twisters and forehead knocks.  One time I did stand up for myself.  I was getting chased around the room and finally I turned and punched one of the guys chasing me square in the jaw.  It stunned him but wasn’t enough.  I was grabbed by another person and thrown to the ground.  I was kicked and punched a few times.  I still struggled and tried to get away until CRACK, a broom was broke across my back.  In defeat I slumped to the ground.  The rest of practice the guys that were involved kept slapping me in the back where the broom left its mark.  This is in no way a reflection of the coach.  He did truly care for the well-being of the athletes.  I came in to wrestling freshmen year weighing 155lbs.  I wrestled at 152lbs, up from the 135lbs I wrestled at in 8th grade. .  I lost the 3 pounds easily throughout the practices.  I got on the scale on day and noticed I was 148lbs.  The next weight class was 145lbs.  I told the coach that I would like to wrestle at the 145 pound weight class.  He was concerned and required my dad to sign off on me losing the 3 pounds.  I went on to only lose 1 match freshmen year and had a lot of fun.  My sophomore year got my first taste of varsity matches.  I competed at 160lbs.  I went 0-4 on varsity but again had a fun year.

That summer we got to meet our new coach, Ted Witulski.  Right away I knew something was different.  He would allow us to come in and drill during the summer.  He couldn’t coach us, but if we asked questions about moves or techniques he would give us information.  Right away he asked about moves we knew and what practices were like.  He gave us his home number and told us we could call at any time.  Once school started he actively recruited people to come out.  He told them to give him two weeks and if they stuck it out for the two weeks and then wanted to quit, he would allow it and there would be no recourse.  If you quit before the two weeks, you were branded not tough enough for wrestling.  I am not sure how many people quit before the two weeks, I don’t think it was many, but our wrestling room was filled.  I once again wrestled at 160lbs after coming in about 180lbs from football.  Coach pushed and pushed our team.  There was no more goofing around during practice or at meets.  Practices were filled with non-stop action with coach jumping in to wrestle us and helping us break through the walls.  I remember practices where I just wanted to stop and rest.  Just about when I thought it was time for a break, we would start another drill.  I would come home from practice, eat something, do a little homework and crash at my desk with pen in hand and face in the book.  I wrestled varsity that year and made it through districts and almost made it to the medal rounds.  That summer I was able to go to a small wrestling camp.  I ended up hurting my left ankle on Wednesday and the Cornhusker State Games was on Sunday.  Pushing through the pain I was able to win the tournament.  My junior year was more than I could imagine.  I qualified for the state wrestling tournament coming just one match from qualifying for the medal rounds.  I was pushed farther than I thought I could, but this was just the beginning.

Senior year had started and while I played football, I couldn’t wait for wrestling season.  That football helped reaffirm one of the reasons I love wrestling.  If you want the varsity spot, you need to beat the person in the spot.  If you win, most of the time it is two of three matches, then you are the new varsity wrestler.  Unlike other sports where politics are in play.  I would get done with football practice and run up to the wrestling room to do some live wrestling with the coach and anyone else that was still there.  That year I was pushed to my limits and then beyond.  About half way through the football season coach Witulski asked how much I was weighing.  I answered that I was around 190-195 pounds.  Giggling he asked what weight I was thinking about wrestling at.  When I answered that I was planning on wrestling at 171 pounds, he started laughing.  Thinking out loud I said that I wouldn’t be very cut at 189 pounds so with a question in my voice I answered 160 pounds?  He responded with a yupe, better start that diet.  The next day coach found me in the hallway and gave me a diet sheet.  I looked it over and noticed that it was around 1200 calories.  As I was about to question the sheet he looked at me and told me you have to eat to lose weight.  Throughout that year I got lessons on diet, exercise, and just how the body handles weight cutting and nutrition.

The team that year was truly a family.  A few of us that had to on a strict diet would meet up in the wrestling room and have lunch.  I would occasionally meet with my classmates for lunch.  They would comment on my lunch.  They would often ask how could I stand being around all the fast food and still eat my celery?  I would just laugh and say just the smell from their food was going to make me over weight.  Few understood the dedication and sacrifice it takes to be a wrestler.  Wrestling season had started and I was pumped.  Coach pulled most of us that had a shot at varsity a side and preceded to let us know that if we really wanted to win, we could have no distractions.  He said something to the fact that focusing on school and wrestling would fill all of our time and attention.  Girls were just going to get in the way of things.  He joking said if it is true love, it will be there after the season.  It was time to focus on that one goal, winning.  Coach Witulski pushed us.  Practices became more and more intense.  It wasn’t just a coach standing by screaming.  He was there in the mix.  He showed us the path.  He was in the pits training with us.  He pushed us.  He showed us the path.  He didn’t just say do this one move and then do this other move.  He hung sheets of paper from the ceiling with different moves.  Each one of the sheets was a different color.  He could say work this series and you could just look up and know the moves to drill.  If you didn’t like doing a single leg tree top, you could work on a single leg running the pipe.  You controlled how you wanted to drill.  I remember practices were I didn’t ever think it was going to end.  Move after move, drill after drill.  Running the hallways to the point of physical exhaustion.  Then you would hear his voice from some corner.  “The mind quits before the body, push through it”, and we did.  The motto of being the most in shape is used by a lot of coaches.  Our team embraced it.  If your match stopped for whatever reason, you were right back in the center of the mat.  Once you were in ready position, then you could rest.  The reasoning’s behind it are simple.  To the referee it shows you are ready to continue the match and makes them wonder why the other person is not set and ready also.  It gets the referee thinking about give a stalling call.  To the opponent, it may be late in the match and both of you have been going like wild men.  You go out of bounds.  You look up trying to catch your breath and you see your opponent hustling to the center of the mat.  You start to get that little bit of doubt in you.  How can he be up and ready and I am laying here gasping for air?  Again, it is the mind pushing your body to do things most people wouldn’t be able to do, but to a wrestler it is just what it is.

Coach Witulski didn’t just change wrestling for us but for everyone in the school.  Most of the time for our home duals the stands were about half full.  It was family and some close friends that would come out and watch.  Our senior night dual was standing room only.  All of the bleachers were full.  The sides were packed.  They had to open the doors to the other gym to allow people to be able to see.  It was a tough duel.  By the time I was up we were down in the team standings. Coach stopped me right before I went on to the mat.  He looked at me right in the eyes.  He told me that my team was depending on me.  I needed a pin and that he needed me to go out there and get things done.  I nodded and took the mat.  The match was back and forth.  There was 40 seconds left on the clock, I was down my 4 or 5 points, and I was on bottom.  I remember looking up at coach and seeing the look of you can do better than this.  I just remember saying to myself no, this isn’t happening.  I trained to hard for this.  Hitting a hard switch I caught the guy off balance.  I was able to put him straight to his back.  With 12 seconds left in the match, I pinned him.  Our team went on to win the rest of the matches and to win the duel.  There are not a lot of matches I remember, but that is second most memorable match I had.

Shortly after this match was districts and then state.  I came off of districts only getting second.  The finals match is one of those matches we wish you could get back.  I had gone against this opponent earlier in the year and won.  That match really looked and felt like I wasn’t in the match.  But now it is state.  Time to put that match behind me.  I was one of the best 16 wrestlers in my class.  Here was my time to prove myself.  This is what I worked for, only to be caught in a move in my first match at state.  Thankfully to friends, family, teammates, and coaches I battled back.  I won my next two matches.  My fourth match of the tournament was against someone I hadn’t seen or really heard about to much except the fact he was an awesome takedown artist.  We went back and forth during the match.  This guy lived up to his takedown mastery.  Both of us were hitting moves and countering.  I remember my lungs being on fire and my muscles twitching with exhaustion.  As we battle through the third and final period, I get a reversal to tie to the match.  I glance over at the clock. 20 seconds left in the match.  I quickly do a self-inventory.  I haven’t been able to stop this guy’s takedown all match.  If I ride him out and we go to overtime, he has a major advantage.  I think that I could give up an escape but not give him enough room so that I have an easy take down.  With the clock ticking down, I let him up with having my hands near his knees.  I see the referee signal the escape.  I pounce across his legs snatching up his legs and driving across his legs.  As we both fall to the ground we hear the whistle from the referee for the end of the match.  I lay there gasping for air when I notice he was also still on the ground.  Who ever won this match made it to the medal rounds.  Almost at the same time we both looked up at each other and then to the referee.  We asked who won.  The referee looked towards my opponent and said he had won.  Either of us had the energy to celebrate or do be upset.  We helped each other up and shook hands.  We walked to the warm up area together.  We both collapsed on the mat.  During the next 20 minutes as I laid there talking to him and replaying the match over and over in my head, a smile came across me.  I had put it out there.  I went for it.  He was better that day.  I couldn’t find what I would have done different in that match that I would change.  I stood up, wiped a few tears from my eyes, gave my opponent a hug and wished him well in the rest of the tournament.  I walked up to waiting family, friends, and teammates.  Looking back, that was my defining match of my wrestling career.  I may not have been blessed with the god given talent as some, but I use every last bit of what I was given and worked my butt off to capitalize on that talent.  I earned my spot at the varsity table.  I competed against the best in the state.  I won some, and I lost some.  I walked away knowing just what I was capable of achieving.

To sum up what wrestling taught me, it taught me what life is about.  There are people who don’t try.  They don’t want to risk looking foolish for a chance at greatness.  There some are who flirt with a chance at greatness but find out that it takes too much.  There are a few that get tastes of greatness but don’t get to feel what it is like to stand on the podium with a medal around their necks.  There are a select few that have the natural talent but don’t push themselves.  They will get to stand at the podium but they won’t truly understand the meaning behind it.  One day they will look back and wonder what if.  And then there are a group that is singled out.  They have the natural abilities and yet look to push themselves farther than most people could even dream.  While they might not understand it, they are who inspire the masses.  Their drive and pushing beyond what is normal causes us dream of greatness.  And the greatest of all these groups are the coaches that push us no matter what group we are in.  Either you are like myself who got just the tastes of greatness but didn’t get to stand on the podium, or you are like my brothers who pushed themselves beyond what most people see as possible, or if you are Jordan Burroughs who inspired a nation with his gold medal matches at the 2012 Olympics, there is always a coach.  They sit on the sidelines letting us get the glory.  They silently celebrate with us.  They cry over every defeat.  If you watch a coach on the side of a mat, you will notice him bending and moving his body as he goes through every move you do.  Wrestling takes boys and makes them men.  Wrestling take girls and makes them women.  You win, you lose, you struggle, and you overcome.  Wrestling isn’t just about two physically fit people in a circle trying to oppose their will on the other.  Wrestling is won days before the match.  It is the 5am runs during the summer.  It is going to that summer camp where you train 12 to 14 hours a day while your classmate sit beside a pool.  Although in your match, it is you against someone else, you know that the people on your side of the mat have your back.  You know because they shared their blood, sweat, and tears with you.  And thanks to wrestling, I know who I am and just what I am capable of doing and that it is more than most.

Splunk>Live KC

I recently spoke at the Splunk>Live Kansas City conference.  I was one of three speakers giving their user experiences working with Splunk.  The speakers along with two other guests also sat in a Q&A session over lunch.  I also had the chance to have dinner with a few of the people that work with Splunk.  I enjoyed speaking with the Splunk employees and other people interested in the Splunk product.  I wish I would have had someone record the talk I gave but I have included the slides below.

 

Installing SNMP through the Command Line – Part 2

I added a batch script I wrote to install SNMP on a bunch of machine back on Jan. 14, 2012 (http://www.anthonyreinke.com/?p=455).  I have since modified the script.  Changing the file from a .bat to a .cmd will allow you to right click and run as administrator on Windows 2008.  Also I noticed in 2008, it defaults in to having the localhost as the only system that can communicate to the SNMP Service.

PsExec.exe @hosts.txt -s -c installsnmp.cmd

Below is the file to download.  Rename the file to installsnmp.cmd
installsnmp.cmd.txt

As always, please contact me if you have questions.

@echo off
cls
REM Detect if the system is Windows Server 2003
systeminfo | find "2003" > nul
if %ERRORLEVEL% == 0 goto 2003
REM Detect if the system is Windows XP
systeminfo | find "XP Pro" > nul
if %ERRORLEVEL% == 0 goto XPPro
REM Detect if the system is Windows XP
systeminfo | find "2008" > nul
if %ERRORLEVEL% == 0 goto 2008
REM If the system is Windows Vista, Windows Server 2008, or higher, 
REM they have the required files built in.
goto ERROR
:2003
REM If Windows 2003, set the path to the i386 directory
REM Note: The path needs to be one level above the i386 directory
REM Example: if the path is \\server\share\windows2003\i386\ then
REM the path would be \\server\share\windows2003\
REM Note that the you need both a 32bit and 64bit versions
if (%PROCESSOR_ARCHITECTURE%) == (AMD64) (
echo Windows Registry Editor Version 5.00
echo.
echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup]
echo "SourcePath"="\\\\server\\share\\Extracted\\Win2003x64\\"
echo "ServicePackSourcePath"="\\\\server\\share\\Extracted\\Win2003x64\\"
) > %temp%\setW2003Path.reg
IF (%PROCESSOR_ARCHITECTURE%) == (x86) (
echo Windows Registry Editor Version 5.00
echo.
echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup]
echo "SourcePath"="\\\\server\\share\\Extracted\\Win2003\\"
echo "ServicePackSourcePath"="\\\\server\\share\\Extracted\\Win2003\\"
) > %temp%\setW2003Path.reg
REM Installing the created Registry File
regedit /s /q %temp%\setW2003Path.reg
goto SNMP
:XPPro
REM If Windows XP Professional, set the path to the i386 directory
REM Note: The path needs to be one level above the i386 directory
REM Example: if the path is \\server\share\windowsXP\i386\ then
REM the path would be \\server\share\windowsXP\
if (%PROCESSOR_ARCHITECTURE%) == (AMD64) (
(
echo Windows Registry Editor Version 5.00
echo.
echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup]
echo "SourcePath"="\\\\server\\share\\Extracted\\XPProx64\\"
echo "ServicePackSourcePath"="\\\\server\\share\\Extracted\\XPProx64\\"
) > %temp%\setXPProPath.reg
) ELSE IF (%PROCESSOR_ARCHITECTURE%) == (x86)
(
echo Windows Registry Editor Version 5.00
echo.
echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup]
echo "SourcePath"="\\\\server\\share\\Extracted\\XPPro\\"
echo "ServicePackSourcePath"="\\\\server\\share\\Extracted\\XPPro\\"
) > %temp%\setXPProPath.reg
)
REM Installing the created Registry File
regedit /s /q %temp%\setXPProPath.reg.reg
goto SNMP
:2008
REM Since 2008 stopped using the sysocmgr.exe to install features, in Vista and higher
REM you need to use the servermanagercmd.exe to add features. A great list of the 
REM features and their command line install string is at:
REM http://www.techrepublic.com/blog/datacenter/install-windows-server-2008-features-with-servermanagercmd/294
servermanagercmd.exe -install SNMP-Services
goto Strings
:SNMP
REM Building the Unattended Install
(
echo ;SetupMgrTag
echo [NetOptionalComponents]
echo SNMP=1
echo [SNMP]
echo Any_Host=YES
) > %temp%\snmp.txt
REM Installing the SNMP application with the Unattended Install
sysocmgr /i:%windir%\inf\sysoc.inf /u:%temp%\snmp.txt
goto Strings
:Strings
REM Removing the public string
(
echo Windows Registry Editor Version 5.00
echo.
echo [-HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\SNMP\Parameters\ValidCommunities]
REM Removing the only allow localhost communication, by default 2008 will only allow the 
REM localhsot to talk to the SNMP service
echo [-HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\services\SNMP\Parameters\PermittedManagers]
REM Setting the SNMP strings
echo.
REM Setting the SNMP Contact Info
echo [HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\SNMP\Parameters\RFC1156Agent]
echo "sysContact"="Server Administrators"
echo "sysLocation"="Server Room"
echo "sysServices"=dword:0000004f
echo.
REM Setting the Read Only and Read Write Communities
echo [HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\SNMP\Parameters\ValidCommunities]
echo "readonly"=dword:00000004
echo "readwrite"=dword:00000008
echo.
REM Creating the Permitted Managers Key
echo [HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\services\SNMP\Parameters\PermittedManagers]
echo.
) > %temp%\setupsnmp.reg
REM Installing the created Registry File
regedit /s /q %temp%\setupsnmp.reg
REM Cleaning Up
IF EXIST %temp%\setupsnmp.reg del %temp%\setupsnmp.reg
IF EXIST %temp%\setW2003Path.reg del %temp%\setW2003Path.reg
IF EXIST %temp%\setXPProPath.reg.reg del %temp%\setXPProPath.reg.reg
IF EXIST %temp%\snmp.txt del %temp%\snmp.txt
echo %COMPUTERNAME% Complete >> \\server\share\SNMP\SNMPInstall.txt
goto END
:ERROR
echo.
echo Could not determine the OS type
pause
goto END
:END

 

Installing SNMP through the Command Line

I needed a way to mass install SNMP to the servers in my environment.  The problem I was having was Microsoft Windows Server 2003 needing files from the CD.  We don’t copy the i386 directory from the CD for two reasons.  We store the files on the network and drive space is limit on a lot of servers.  The batch script will check if the server is 2003.  If it is 2003, it will point the install cd to a network path or a local path.  Next it builds the  unattended install file.  Once the file is written, the system will add the SNMP feature per the unattended file.  After SNMP is installed, the registry keys are set for the SNMP community strings.  Lastly the script removes the temporary files it created.

Use this script in combination to PSTools’ PSExec and you can mass install.  Create a list of systems you want to install this on and call it hosts.txt.  Each server needs to be on it’s own line and it is best to use the fully qualified name or IP Address.  Copy the hosts.txt and installsnmp.bat file in to your PSTools directory and run the following command:

PsExec.exe @hosts.txt -s -c installsnmp.bat

Download the Install SNMP Batch File, just rename to a .bat file.

 


@echo off

echo %COMPUTERNAME% Started >> \\server\share\SNMP\SNMPInstall.txt

REM Detect if the system is Windows Server 2003
systeminfo | find "2003" > nul
if %ERRORLEVEL% == 0 goto 2003

REM Detect if the system is Windows XP
systeminfo | find "XP Pro" > nul
if %ERRORLEVEL% == 0 goto XPPro

REM If the system is Windows Vista, Windows Server 2008, or higher, 
REM they have the required files built in.
goto SNMP

:2003
REM If Windows 2003, set the path to the i386 directory
REM Note: The path needs to be one level above the i386 directory
REM Example: if the path is \\server\share\windows2003\i386\ then
REM the path would be \\server\share\windows2003\
REM Note that the you need both a 32bit and 64bit versions

if (%PROCESSOR_ARCHITECTURE%) == (AMD64) (
(
echo Windows Registry Editor Version 5.00
echo.
echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup]
echo "SourcePath"="\\\\server\\share\\Extracted\\Win2003x64\\"
echo "ServicePackSourcePath"="\\\\server\\share\\Extracted\\Win2003x64\\"
) > %temp%\setW2003Path.reg
) ELSE IF (%PROCESSOR_ARCHITECTURE%) == (x86)
(
echo Windows Registry Editor Version 5.00
echo.
echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup]
echo "SourcePath"="\\\\server\\share\\Extracted\\Win2003\\"
echo "ServicePackSourcePath"="\\\\server\\share\\Extracted\\Win2003\\"
) > %temp%\setW2003Path.reg
)

REM Installing the created Registry File
regedit /s /q %temp%\setW2003Path.reg

goto SNMP

:XPPro
REM If Windows XP Professional, set the path to the i386 directory
REM Note: The path needs to be one level above the i386 directory
REM Example: if the path is \\server\share\windowsXP\i386\ then
REM the path would be \\server\share\windowsXP\
if (%PROCESSOR_ARCHITECTURE%) == (AMD64) (
(
echo Windows Registry Editor Version 5.00
echo.
echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup]
echo "SourcePath"="\\\\server\\share\\Extracted\\XPProx64\\"
echo "ServicePackSourcePath"="\\\\server\\share\\Extracted\\XPProx64\\"
) > %temp%\setXPProPath.reg
) ELSE IF (%PROCESSOR_ARCHITECTURE%) == (x86)
(
echo Windows Registry Editor Version 5.00
echo.
echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup]
echo "SourcePath"="\\\\server\\share\\Extracted\\XPPro\\"
echo "ServicePackSourcePath"="\\\\server\\share\\Extracted\\XPPro\\"
) > %temp%\setXPProPath.reg
)

REM Installing the created Registry File
regedit /s /q %temp%\setXPProPath.reg.reg

goto SNMP

:SNMP
REM Building the Unattended Install

(
echo ;SetupMgrTag
echo [NetOptionalComponents]
echo SNMP=1
echo [SNMP]
echo Any_Host=YES
) > %temp%\snmp.txt

REM Installing the SNMP application with the Unattended Install

sysocmgr /i:%windir%\inf\sysoc.inf /u:%temp%\snmp.txt

goto Strings

:2008
REM Since 2008 stopped using the sysocmgr.exe to install features, in Vista and higher
REM you need to use the servermanagercmd.exe to add features. A great list of the 
REM features and their command line install string is at:
REM http://www.techrepublic.com/blog/datacenter/install-windows-server-2008-features-with-servermanagercmd/294

servermanagercmd.exe -install SNMP-Services

goto Strings

:Strings

REM Removing the public string
(
echo Windows Registry Editor Version 5.00
echo.
echo [-HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\SNMP\Parameters\ValidCommunities]

REM Setting the SNMP strings
echo.
echo [HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\SNMP\Parameters\RFC1156Agent]
echo "sysContact"="Server Administrators"
echo "sysLocation"="Server Room"
echo "sysServices"=dword:0000004f
echo.
echo [HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\SNMP\Parameters\ValidCommunities]
echo "readonly"=dword:00000004
echo "readwrite"=dword:00000008
) > %temp%\setupsnmp.reg

REM Installing the created Registry File

regedit /s /q %temp%\setupsnmp.reg

REM Cleaning Up

IF EXIST %temp%\setupsnmp.reg del %temp%\setupsnmp.reg
IF EXIST %temp%\setW2003Path.reg del %temp%\setW2003Path.reg
IF EXIST %temp%\setXPProPath.reg.reg del %temp%\setXPProPath.reg.reg
IF EXIST %temp%\snmp.txt del %temp%\snmp.txt

 

echo %COMPUTERNAME% Complete >> \\server\share\SNMP\SNMPInstall.txt


Automating a New Email Profile

I have been helping a company move to a new cloud based email system.  They needed to update everyone’s mail profile.  In this follow VBScript, it builds a .prf file to be imported in with the correct fields for the user and servers.  Near the top of the script there is a section to be filled out by a person that knows the Exchange environment, Exchange Administrator.

‘ Define our servers and paths 
strProxy = “”
strAutoDiscoverProxy = “”
strProfileName = “”
strHomeServer = “”
strRPCProxyPrincipalName = “”
 

The script will ask the user their primary email address.  For the company I was helping out they had multiple email domains so we needed them to select their primary.  It then will ask them to confirm what they typed.

SetupNewOutlook

#####################################

‘++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
‘ Add email profile for Another Exchange Provider
‘++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Option Explicit
On Error Resume Next’ Declare our varibles
Dim template, strInput, intAnswer, strProxy, strAutoDiscoverProxy, strProfileName, strHomeServer, strRPCProxyPrincipalName’ Define our servers and paths                                  Examples
strProxy = “”                                                                   ‘ strProxy = “webmail.yourdomain.com”
strAutoDiscoverProxy = “”                                      ‘ strAutoDiscoverProxy = “https://webmail.yourdomain.com/autodiscoverproxy/autodiscover.xml”
strProfileName = “”                                                     ‘ strProfileName = “New Cloud Email”
strHomeServer = “”                                                     ‘ strHomeServer = “MyExchangeServer”
strRPCProxyPrincipalName = “”                            ‘ strRPCProxyPrincipalName = “msstd:webmail.yourdomain.com”‘ This loop section is here to have the user verify their email address
‘ Starting the Loop. This will loop from this point until the answer is Yes
Do Until intAnswer = vbYes

‘ Asking the user their primary email address
strInput = UserInput( “Please enter your primary email address:” )

‘ This is asking the user to confirm their primary email address
intAnswer = _
Msgbox(“Completing reconfiguration of Outlook for email address: ” & strInput & vbCr & “This is correct?”, _
vbYesNo, “Confirm Email Address”)

‘ This will loop the script back to the start of the Loop function. If the user click
‘ Yes, then the function will exit the loop. If the user answered No, the function will
‘ start over and prompt the user for their primary email address.
Loop

Function UserInput( myPrompt )
‘ This function prompts the user for some input.
‘ When the script runs in CSCRIPT.EXE, StdIn is used,
‘ otherwise the VBScript InputBox( ) function is used.
‘ myPrompt is the the text used to prompt the user for input.
‘ The function returns the input typed either on StdIn or in InputBox( ).
‘ Written by Rob van der Woude
‘ http://www.robvanderwoude.com
‘ Check if the script runs in CSCRIPT.EXE
If UCase( Right( WScript.FullName, 12 ) ) = “\CSCRIPT.EXE” Then
‘ If so, use StdIn and StdOut
WScript.StdOut.Write myPrompt & ” “
UserInput = WScript.StdIn.ReadLine
Else
‘ If not, use InputBox( )
UserInput = InputBox( myPrompt )
End If
End Function

template = “;Automatically generated PRF file” & VbCrLF &_
VbCrLF &_
“; **************************************************************” & VbCrLF &_
“; Section 1 – Profile Defaults” & VbCrLF &_
“; **************************************************************” & VbCrLF &_
VbCrLF &_
“[General]” & VbCrLF &_
“Custom=1” & VbCrLF &_
“ProfileName=Cloud Email” & VbCrLF &_
“DefaultProfile=No” & VbCrLF &_
“OverwriteProfile=No” & VbCrLF &_
“ModifyDefaultProfileIfPresent=FALSE” & VbCrLF &_
“BackupProfile=No ” & VbCrLF &_
“DefaultStore=Service1” & VbCrLF &_
VbCrLF &_
“; **************************************************************” & VbCrLF &_
“; Section 2 – Services in Profile” & VbCrLF &_
“; **************************************************************” & VbCrLF &_
VbCrLF &_
“[Service List]” & VbCrLF &_
“ServiceX=Microsoft Outlook Client” & VbCrLF &_
“ServiceEGS=Exchange Global Section” & VbCrLF &_
“Service1=Microsoft Exchange Server” & VbCrLF &_
“ServiceEGS=Exchange Global Section” & VbCrLF &_
“Service2=Outlook Address Book” & VbCrLF &_
VbCrLF &_
“;***************************************************************” & VbCrLF &_
“; Section 3 – List of internet accounts” & VbCrLF &_
“;***************************************************************” & VbCrLF &_
VbCrLF &_
“[Internet Account List]” & VbCrLF &_
VbCrLF &_
“;***************************************************************” & VbCrLF &_
“; Section 4 – Default values for each service.” & VbCrLF &_
“;***************************************************************” & VbCrLF &_
VbCrLF &_
“[ServiceX]” & VbCrLF &_
“CachedExchangeMode=0x00000002” & VbCrLF &_
“CachedExchangeSlowDetect=TRUE” & VbCrLF &_
VbCrLF &_
“[ServiceEGS]” & VbCrLF &_
“CachedExchangeConfigFlags=0x00000100” & VbCrLF &_
“MailboxName=” & strInput & VbCrLF &_
“HomeServer=” & strHomeServer & VbCrLF &_
“RPCoverHTTPflags=0x002f” & VbCrLF &_
“RPCProxyServer=” & strProxy & VbCrLF &_
“RPCProxyPrincipalName=msstd:” & strRPCProxyPrincipalName & VbCrLF &_
“RPCProxyAuthScheme=0x0001” & VbCrLF &_
VbCrLF &_
“[Service1]” & VbCrLF &_
“OverwriteExistingService=No” & VbCrLF &_
“UniqueService=No” & VbCrLF &_
“MailboxName=” & strInput & VbCrLF &_
“HomeServer=” & strHomeServer & VbCrLF &_
“AccountName=Microsoft Exchange Server” & VbCrLF &_
VbCrLF &_
“;***************************************************************” & VbCrLF &_
“; Section 5 – Values for each internet account.” & VbCrLF &_
“;***************************************************************” & VbCrLF &_
VbCrLF &_
“;***************************************************************” & VbCrLF &_
“; Section 6 – Mapping for profile properties” & VbCrLF &_
“;***************************************************************” & VbCrLF &_
VbCrLF &_
“[Microsoft Exchange Server]” & VbCrLF &_
“ServiceName=MSEMS” & VbCrLF &_
“MDBGUID=5494A1C0297F101BA58708002B2A2517” & VbCrLF &_
“MailboxName=PT_STRING8,0x6607” & VbCrLF &_
“HomeServer=PT_STRING8,0x6608” & VbCrLF &_
“OfflineAddressBookPath=PT_STRING8,0x660E” & VbCrLF &_
“OfflineFolderPath=PT_STRING8,0x6610” & VbCrLF &_
VbCrLF &_
“[Exchange Global Section]” & VbCrLF &_
“SectionGUID=13dbb0c8aa05101a9bb000aa002fc45a” & VbCrLF &_
“MailboxName=PT_STRING8,0x6607” & VbCrLF &_
“HomeServer=PT_STRING8,0x6608” & VbCrLF &_
“RPCoverHTTPflags=PT_LONG,0x6623” & VbCrLF &_
“RPCProxyServer=PT_UNICODE,0x6622” & VbCrLF &_
“RPCProxyPrincipalName=PT_UNICODE,0x6625” & VbCrLF &_
“RPCProxyAuthScheme=PT_LONG,0x6627” & VbCrLF &_
“CachedExchangeConfigFlags=PT_LONG,0x6629” & VbCrLF &_
VbCrLF &_
“[Microsoft Mail]” & VbCrLF &_
“ServiceName=MSFS” & VbCrLF &_
“ServerPath=PT_STRING8,0x6600” & VbCrLF &_
“Mailbox=PT_STRING8,0x6601” & VbCrLF &_
“Password=PT_STRING8,0x67f0” & VbCrLF &_
“RememberPassword=PT_BOOLEAN,0x6606” & VbCrLF &_
“ConnectionType=PT_LONG,0x6603” & VbCrLF &_
“UseSessionLog=PT_BOOLEAN,0x6604” & VbCrLF &_
“SessionLogPath=PT_STRING8,0x6605” & VbCrLF &_
“EnableUpload=PT_BOOLEAN,0x6620” & VbCrLF &_
“EnableDownload=PT_BOOLEAN,0x6621” & VbCrLF &_
“UploadMask=PT_LONG,0x6622” & VbCrLF &_
“NetBiosNotification=PT_BOOLEAN,0x6623” & VbCrLF &_
“NewMailPollInterval=PT_STRING8,0x6624” & VbCrLF &_
“DisplayGalOnly=PT_BOOLEAN,0x6625” & VbCrLF &_
“UseHeadersOnLAN=PT_BOOLEAN,0x6630” & VbCrLF &_
“UseLocalAdressBookOnLAN=PT_BOOLEAN,0x6631” & VbCrLF &_
“UseExternalToHelpDeliverOnLAN=PT_BOOLEAN,0x6632” & VbCrLF &_
“UseHeadersOnRAS=PT_BOOLEAN,0x6640” & VbCrLF &_
“UseLocalAdressBookOnRAS=PT_BOOLEAN,0x6641” & VbCrLF &_
“UseExternalToHelpDeliverOnRAS=PT_BOOLEAN,0x6639” & VbCrLF &_
“ConnectOnStartup=PT_BOOLEAN,0x6642” & VbCrLF &_
“DisconnectAfterRetrieveHeaders=PT_BOOLEAN,0x6643” & VbCrLF &_
“DisconnectAfterRetrieveMail=PT_BOOLEAN,0x6644” & VbCrLF &_
“DisconnectOnExit=PT_BOOLEAN,0x6645” & VbCrLF &_
“DefaultDialupConnectionName=PT_STRING8,0x6646” & VbCrLF &_
“DialupRetryCount=PT_STRING8,0x6648” & VbCrLF &_
“DialupRetryDelay=PT_STRING8,0x6649” & VbCrLF &_
VbCrLF &_
“[Personal Folders]” & VbCrLF &_
“ServiceName=MSPST MS” & VbCrLF &_
“Name=PT_STRING8,0x3001” & VbCrLF &_
“PathToPersonalFolders=PT_STRING8,0x6700 ” & VbCrLF &_
“RememberPassword=PT_BOOLEAN,0x6701” & VbCrLF &_
“EncryptionType=PT_LONG,0x6702” & VbCrLF &_
“Password=PT_STRING8,0x6703” & VbCrLF &_
VbCrLF &_
“[Unicode Personal Folders]” & VbCrLF &_
“ServiceName=MSUPST MS” & VbCrLF &_
“Name=PT_UNICODE,0x3001” & VbCrLF &_
“PathToPersonalFolders=PT_STRING8,0x6700 ” & VbCrLF &_
“RememberPassword=PT_BOOLEAN,0x6701” & VbCrLF &_
“EncryptionType=PT_LONG,0x6702” & VbCrLF &_
“Password=PT_STRING8,0x6703” & VbCrLF &_
VbCrLF &_
“[Outlook Address Book]” & VbCrLF &_
“ServiceName=CONTAB” & VbCrLF &_
VbCrLF &_
“[LDAP Directory]” & VbCrLF &_
“ServiceName=EMABLT” & VbCrLF &_
“ServerName=PT_STRING8,0x6600” & VbCrLF &_
“UserName=PT_STRING8,0x6602” & VbCrLF &_
“UseSSL=PT_BOOLEAN,0x6613” & VbCrLF &_
“UseSPA=PT_BOOLEAN,0x6615” & VbCrLF &_
“DisableVLV=PT_LONG,0x6616” & VbCrLF &_
“DisplayName=PT_STRING8,0x3001” & VbCrLF &_
“ConnectionPort=PT_STRING8,0x6601” & VbCrLF &_
“SearchTimeout=PT_STRING8,0x6607” & VbCrLF &_
“MaxEntriesReturned=PT_STRING8,0x6608” & VbCrLF &_
“SearchBase=PT_STRING8,0x6603” & VbCrLF &_
VbCrLF &_
“[Microsoft Outlook Client]” & VbCrLF &_
“SectionGUID=0a0d020000000000c000000000000046” & VbCrLF &_
“FormDirectoryPage=PT_STRING8,0x0270” & VbCrLF &_
“WebServicesLocation=PT_STRING8,0x0271” & VbCrLF &_
“ComposeWithWebServices=PT_BOOLEAN,0x0272” & VbCrLF &_
“PromptWhenUsingWebServices=PT_BOOLEAN,0x0273” & VbCrLF &_
“OpenWithWebServices=PT_BOOLEAN,0x0274” & VbCrLF &_
“CachedExchangeMode=PT_LONG,0x041f” & VbCrLF &_
“CachedExchangeSlowDetect=PT_BOOLEAN,0x0420” & VbCrLF &_
VbCrLF &_
“[Personal Address Book]” & VbCrLF &_
“ServiceName=MSPST AB” & VbCrLF &_
“NameOfPAB=PT_STRING8,0x001e3001” & VbCrLF &_
“Path=PT_STRING8,0x001e6600” & VbCrLF &_
“ShowNamesBy=PT_LONG,0x00036601” & VbCrLF &_
VbCrLF &_
“; ************************************************************************” & VbCrLF &_
“; Section 7 – Mapping for internet account properties. DO NOT MODIFY.” & VbCrLF &_
“; ************************************************************************” & VbCrLF &_
VbCrLF &_
“[I_Mail]” & VbCrLF &_
“AccountType=POP3” & VbCrLF &_
“;— POP3 Account Settings —” & VbCrLF &_
“AccountName=PT_UNICODE,0x0002” & VbCrLF &_
“DisplayName=PT_UNICODE,0x000B” & VbCrLF &_
“EmailAddress=PT_UNICODE,0x000C” & VbCrLF &_
“;— POP3 Account Settings —” & VbCrLF &_
“POP3Server=PT_UNICODE,0x0100” & VbCrLF &_
“POP3UserName=PT_UNICODE,0x0101” & VbCrLF &_
“POP3UseSPA=PT_LONG,0x0108” & VbCrLF &_
“Organization=PT_UNICODE,0x0107” & VbCrLF &_
“ReplyEmailAddress=PT_UNICODE,0x0103” & VbCrLF &_
“POP3Port=PT_LONG,0x0104” & VbCrLF &_
“POP3UseSSL=PT_LONG,0x0105” & VbCrLF &_
“; — SMTP Account Settings —” & VbCrLF &_
“SMTPServer=PT_UNICODE,0x0200” & VbCrLF &_
“SMTPUseAuth=PT_LONG,0x0203” & VbCrLF &_
“SMTPAuthMethod=PT_LONG,0x0208” & VbCrLF &_
“SMTPUserName=PT_UNICODE,0x0204” & VbCrLF &_
“SMTPUseSPA=PT_LONG,0x0207” & VbCrLF &_
“ConnectionType=PT_LONG,0x000F” & VbCrLF &_
“ConnectionOID=PT_UNICODE,0x0010” & VbCrLF &_
“SMTPPort=PT_LONG,0x0201” & VbCrLF &_
“SMTPUseSSL=PT_LONG,0x0202” & VbCrLF &_
“ServerTimeOut=PT_LONG,0x0209” & VbCrLF &_
“LeaveOnServer=PT_LONG,0x1000” & VbCrLF &_
VbCrLF &_
“[IMAP_I_Mail]” & VbCrLF &_
“AccountType=IMAP” & VbCrLF &_
“;— IMAP Account Settings —” & VbCrLF &_
“AccountName=PT_UNICODE,0x0002” & VbCrLF &_
“DisplayName=PT_UNICODE,0x000B” & VbCrLF &_
“EmailAddress=PT_UNICODE,0x000C” & VbCrLF &_
“;— IMAP Account Settings —” & VbCrLF &_
“IMAPServer=PT_UNICODE,0x0100” & VbCrLF &_
“IMAPUserName=PT_UNICODE,0x0101” & VbCrLF &_
“IMAPUseSPA=PT_LONG,0x0108” & VbCrLF &_
“Organization=PT_UNICODE,0x0107” & VbCrLF &_
“ReplyEmailAddress=PT_UNICODE,0x0103” & VbCrLF &_
“IMAPPort=PT_LONG,0x0104” & VbCrLF &_
“IMAPUseSSL=PT_LONG,0x0105” & VbCrLF &_
“; — SMTP Account Settings —” & VbCrLF &_
“SMTPServer=PT_UNICODE,0x0200” & VbCrLF &_
“SMTPUseAuth=PT_LONG,0x0203” & VbCrLF &_
“SMTPAuthMethod=PT_LONG,0x0208” & VbCrLF &_
“SMTPUserName=PT_UNICODE,0x0204” & VbCrLF &_
“SMTPUseSPA=PT_LONG,0x0207” & VbCrLF &_
“ConnectionType=PT_LONG,0x000F” & VbCrLF &_
“ConnectionOID=PT_UNICODE,0x0010” & VbCrLF &_
“SMTPPort=PT_LONG,0x0201” & VbCrLF &_
“SMTPUseSSL=PT_LONG,0x0202” & VbCrLF &_
“ServerTimeOut=PT_LONG,0x0209” & VbCrLF &_
“CheckNewImap=PT_LONG,0x1100” & VbCrLF &_
“RootFolder=PT_UNICODE,0x1101” & VbCrLF &_
VbCrLF &_
“[INET_HTTP]” & VbCrLF &_
“AccountType=HOTMAIL” & VbCrLF &_
“Account=PT_UNICODE,0x0002” & VbCrLF &_
“HttpServer=PT_UNICODE,0x0100” & VbCrLF &_
“UserName=PT_UNICODE,0x0101” & VbCrLF &_
“Organization=PT_UNICODE,0x0107” & VbCrLF &_
“UseSPA=PT_LONG,0x0108” & VbCrLF &_
“TimeOut=PT_LONG,0x0209” & VbCrLF &_
“Reply=PT_UNICODE,0x0103” & VbCrLF &_
“EmailAddress=PT_UNICODE,0x000C” & VbCrLF &_
“FullName=PT_UNICODE,0x000B” & VbCrLF &_
“Connection Type=PT_LONG,0x000F” & VbCrLF &_
“ConnectOID=PT_UNICODE,0x0010” & VbCrLF

Dim objShell, fso
Set objShell = WScript.CreateObject(“WScript.Shell”)
Set fso = CreateObject(“Scripting.FileSystemObject”)

‘Check for valid windows version
If Not CheckWindowsVersion Then
ExitWithError(“UnsupportedVersion”)
End If

‘Get Outlook Path
Dim outlookPath
outlookPath = GetOutlookPath
If outlookPath = “” Then
ExitWithError(“OutlookNotFound”)
End If

‘Check that Outlook does not running
Dim answer
Do While True
If CheckOutlookIsRunning Then
answer = MsgBox(GetString(“OutlookIsRunning”), vbRetryCancel ,GetString (“MessageCaption”))
If answer = vbCancel Then
WScript.Quit
End If
Else
Exit Do
End If
Loop

‘Adjust Outlook registry settings
AdjustSettings

‘ Configure Autodiscover for Custom email address
Dim customEmail
customEmail = “”

If customEmail <> “” Then
ConfigureAutodiscover customEmail
End If

‘Create temporary file for Outlook profile
Dim tempFile, tempFileName
tempFileName = GetTempFileName
If Err.Number <> 0 Then
ExitWithError(“ProfileCreateError”)
End If
Set tempFile = fso.CreateTextFile(tempFileName, true, true)
If Err.Number <> 0 Then
ExitWithError(“ProfileCreateError”)
End If

‘Write profile to file
tempFile.Write(template)
If Err.Number <> 0 Then
ExitWithError(“ProfileWriteError”)
End If
tempFile.Close

‘Start Outlook
objShell.Exec(outlookPath + ” /importprf “”” + tempFileName + “”””)

Function CheckWindowsVersion

On Error Resume Next
Dim objWMI, colOS, objOS, version
set objWMI = GetObject(“winmgmts:\\.\root\cimv2”)
set colOS = objWMI.InstancesOf(“Win32_OperatingSystem”)

For Each objOS in colOS
version = objOS.Version
If objOS.OSType = 18 Then
If Left(version, 1) > 5 Then
‘ Windows Vista or Windows Server 2008
CheckWindowsVersion = True
Exit Function
ElseIf Left(version, 1) = 5 And Mid(version, 3, 1) = 2 Then
If objOS.OtherTypeDescription = “R2” Then
‘ Windows Server 2003 R2
CheckWindowsVersion = True
Exit Function
ElseIf objOS.ProductType = 1 Then
‘ Windows XP Professional x64 Edition
CheckWindowsVersion = True
Exit Function
Else
‘ Windows Server 2003
If objOS.ServicePackMajorVersion = 0 Then
‘ no any Service Pack
CheckWindowsVersion = False
Exit Function
End If
CheckWindowsVersion = True
Exit Function
End If
ElseIf Left(version, 1) = 5 And Mid(version, 3, 1) = 1 Then
‘Microsoft Windows XP
If objOS.ServicePackMajorVersion > 1 Then
‘ SP2 or later
CheckWindowsVersion = True
Exit Function
ElseIf objOS.ServicePackMajorVersion = 1 Then
‘ SP1, check for installed KB331320
Err.Clear
objShell.RegRead(“HKLM\SOFTWARE\Microsoft\Updates\Windows XP\SP1\KB331320\”)
If Err.Number = 0 Then
CheckWindowsVersion = True
Exit Function
End If
End If
End If
End If
Next
CheckWindowsVersion = False

End Function

Function GetOutlookPath

On Error Resume Next
Dim CLSID, path

‘ First of all check simple location
path = objShell.RegRead(“HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\OUTLOOK.EXE\”)
If path <> “” Then
GetOutlookPath = path
Exit Function
End If

CLSID = objShell.RegRead(“HKLM\Software\Classes\Outlook.Application\CLSID\”)
If Err.Number <> 0 Then
GetOutlookPath “”
Exit Function
End If
path = objShell.RegRead(“HKLM\Software\Classes\CLSID\” & CLSID & “\LocalServer32\”)

‘ Does need to check alternative path ?
if path = “” Then
path = objShell.RegRead(“HKLM\SOFTWARE\Wow6432Node\Classes\CLSID\” & CLSID & “\LocalServer32\”)
End If

‘ If we have an error path will be empty
GetOutlookPath = path

End Function

Function CheckOutlookIsRunning

On Error Resume Next
Dim objWMIService, processList
Set objWMIService = GetObject(“winmgmts:\\.\root\cimv2”)
Set processList = objWMIService.ExecQuery(“Select * from Win32_Process Where Name = “”outlook.exe”””)
If processList.Count > 0 Then
CheckOutlookIsRunning = True
Exit Function
End If
CheckOutlookIsRunning = False

End Function

Sub AdjustSettings

objShell.RegWrite “HKCU\Software\Microsoft\Exchange\Client\Options\PickLogonProfile”, “1”, “REG_SZ”

End Sub

Function GetTempFileName

Dim tfolder, tname, tfile
Const TemporaryFolder = 2
Set tfolder = fso.GetSpecialFolder(TemporaryFolder)
tname = fso.GetTempName
tfile = fso.BuildPath(tfolder.Path, tname)
GetTempFileName = tfile

End Function

Function ExitWithError(stringId)

MsgBox GetString(stringId), vbOKOnly, GetString(“MessageCaption”)
WScript.Quit

End Function

Function GetString(stringId)

Dim messageCaption, outlookNotFound, outlookIsRunning, profileCreateError, profileWriteError, unsupportedVersion
messageCaption = “Outlook Profile Configuration Script”
outlookNotFound = “Unable to locate Microsoft Outlook installation path.”
outlookIsRunning = “Configuration script has determined that Microsoft Outlook is running. Please shut down it and then click Retry.”
profileCreateError = “Unable to create a temporary file for profile.”
profileWriteError = “Unable to save profile into temporary file.”
unsupportedVersion = “Unsupported version of Microsoft Windows. ” & vbLf & “” & vbLf & “The following versions of Microsoft Windows are supported: ” & vbLf & ” – Microsoft Windows XP with Service Pack 2 ” & vbLf & ” – Windows Server 2003 with Service Pack 1 ” & vbLf & ” – or a later operating system”
Dim retStr
Select Case stringId
Case “MessageCaption”
If messageCaption = “” Or Mid(messageCaption, 2, 1) = “4” Then
retStr = “Outlook Profile Configuration Script”
Else
retStr = messageCaption
End If
Case “OutlookNotFound”
If outlookNotFound = “” Or Mid(outlookNotFound, 2, 1) = “5” Then
retStr = “Unable to locate Microsoft Outlook installation path.”
Else
retStr = outlookNotFound
End If
Case “OutlookIsRunning”
If outlookIsRunning = “” Or Mid(outlookIsRunning, 2, 1) = “6” Then
retStr = “Configuration script has determined that Microsoft Outlook is running. Please shut down it and then click Retry.”
Else
retStr = outlookIsRunning
End If
Case “ProfileCreateError”
If profileCreateError = “” Or Mid(profileCreateError, 2, 1) = “7” Then
retStr = “Unable to create a temporary file for profile.”
Else
retStr = profileCreateError
End If
Case “profileWriteError”
If profileWriteError = “” Or Mid(profileWriteError, 2, 1) = “8” Then
retStr = “Unable to save profile into temporary file.”
Else
retStr = profileWriteError
End If
Case “UnsupportedVersion”
If unsupportedVersion = “” Or Mid(unsupportedVersion, 2, 1) = “9” Then
retStr = “Unsupported version of Microsoft Windows. ” & vbLf & “” & vbLf & “The following versions of Microsoft Windows are supported: ” & vbLf & ” – Microsoft Windows XP with Service Pack 2 ” & vbLf & ” – Windows Server 2003 with Service Pack 1 ” & vbLf & ” – or a later operating system”
Else
retStr = unsupportedVersion
End If
Case Else
retStr = stringId
End Select
GetString = retStr
End Function

Sub ConfigureAutodiscover(email)

On Error Resume Next
Dim configTemplate
configTemplate = “<?xml version=””1.0″” encoding=””utf-8″”?>” & VbCrLF &_
“<Autodiscover xmlns=””http://schemas.microsoft.com/exchange/autodiscover/responseschema/2006″”>” & VbCrLF &_
” <Response xmlns=””http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a””>” & VbCrLF &_
” <Account>” & VbCrLF &_
” <AccountType>email</AccountType>” & VbCrLF &_
” <Action>redirectUrl</Action>” & VbCrLF &_
” <RedirectUrl>” & strAutoDiscoverProxy & “</RedirectUrl>” & VbCrLF &_
” </Account>” & VbCrLF &_
” </Response>” & VbCrLF &_
“</Autodiscover>” & VbCrLF

Dim folder
Dim objEnv
‘ Get collection by using the Environment property.
Set objEnv = objShell.Environment(“Process”)
folder = objEnv(“APPDATA”) + “\Outlook\”

‘ Check that Outlook is available
Dim ver
ver = objShell.RegRead(“HKCR\Outlook.Application\CurVer\”)
If Err.Number <> 0 Then
Exit Sub
End If

‘ Outlook.Application.XX -> XX
ver = Right(ver, 2)

Dim mailDomain, configFilePath, configFile
mailDomain = Mid(email, Instr(email, “@”) + 1)
If Not fso.FolderExists(folder) Then
fso.CreateFolder(folder)
End If
configFilePath = folder & mailDomain & “.xml”
Set configFile = fso.CreateTextFile(configFilePath, True)
configFile.Write(configTemplate)
configFile.Close
objShell.RegWrite “HKCU\Software\Microsoft\Office\” & ver & “.0\Outlook\AutoDiscover\” & mailDomain, configFilePath, “REG_SZ”
End Sub

Cisco Routers, Stop the Stopping

In my current job I am also the network guy.  It is not a skill set I am strong in but I am learning A LOT.  One of the things I have just been dealing with is the “—MORE —” in the putty screen when I issue a command that goes beyond my current screen height.  When I do a “show config” or “show ip route”, I get a few pages of information back.  If I want to then copy it off I have to go back and remove the “— MORE —“.  I just found a command that is saving me.

“terminal length 0”

Setting the terminal length to zero tells the router to not do a page break.  WOW, is this my new favorite command!