Tuesday, February 15, 2011

Windows Batch File for Delayed Auto Shutdown

I frequently run large downloads or maintenance activities like defragmenting manually at night. I am of the camp that believes personal computers should be shut off when not in use for power consumption, security, and unnecessary wear and tear reasons. I shutdown my personal equipment every time I believe it will be idle for more than an hour or two. As such, I wanted a way to shut down my computer in a delayed fashion. I finally got sick of typing the shutdown command every night so I wrote a batch file quick and thought I would share it with the world.

It takes hours and minutes (whole numbers only, no decimals) and converts them into the needed seconds for the shutdown command. I slapped it on my desktop and named it "go_away.bat" and now I can just right-click and select "Run as Administrator," enter the hours, and enter the minutes.

[code]
@ECHO OFF
set /p hrs=How many hours would you like before the computer shuts down?:
set /p min=How many minutes would you like before the computer shuts down?:
set /a sec=%hrs%*60*60
set /a fin=%min%*60+%sec%
shutdown /s /t %fin% /d p:4:1
[/code]

Thanks for reading.

Monday, February 7, 2011

VMWorld 2011

Sorry I have been offline for a while. I moved to Pittsburgh and had some personal issues.

After being offline for a while, I thought I would come back with something that is hard to find - the location of VMWorld 2011. There has been some speculation, but I have some information that leads me to believe it will be at the "Venetian Resort - Hotel - Casino, Sands Expo & Convention Center".

Hope to see you there.

Thanks for reading.

Tuesday, September 7, 2010

My College Rant

Right after high school, I went to Frostburg State University. When I was awake, it was ok I guess. I really did not learn anything in one semester other than college really was not for me.

Undaunted I went to DeVry Institute of Technology in Decatur, GA. I went there for three trimesters. The faculty I had was ok. They were in general knowledgeable of their subject areas and somewhat good at teaching although there were some exceptions to that (in the bad way). The experience I walked away from DeVry with was the extreme expenditure (well over $200 per in the mid 90's) and a VERY bad taste in my mouth for DeVry's idea of "customer service." The students were looked down upon by the administrative staff and even the elder students whom I was generally friends with were treated like the dumbest of 18 year old kids. I tried to drop out of my third trimester but was told I missed the drop add period which minus holidays and weekends was literally two days. $9,000 in student loans later, lesson learned and I was turned off of college forever.

So now, after not having kept up with my education as I should have, I found myself unemployed and unable to get past HR screeners because of my education. After much research with the Montgomery GI Bill (my only known financial aid other than traditional student loans) I decided I had to go back to college. After comparing a few options I chose the University of Phoenix. That allowed me to get student loans to pay for the courses up front so that I could be reimbursed by the Montgomery GI Bill (something I could not do at places like New Horizons which was my first choice). Now enrolled at Axia College of University of Phoenix for an Associate of Arts degree in Information Technology, I realize I have made a mistake again. The cost and amount of garbage I have to go through to get the knowledge I am after is not work it but I am stuck on this path for the moment. On top of that, University of Phoenix is not much better than the other brick and mortar schools I attended previously.

The "facilitators" (Axia College does not have Professors or even instructors) seem to rarely know or care that much about what they are "teaching." I have had a few that stayed on top of their work and went out of their way to try to help struggling students but it has been about a 50/50 mix. Their student site seems to have regular, although infrequent, problems. The Library is pretty hard to use unless you are a librarian and understand in detail the information organization systems that librarians use. The library materials also time out quickly requiring re-login even if you are still active on the site (like reading a long piece of material). One class I have coming up actually has a book other than the text book as recommended almost to the point of being required for the class. Why still use that text book if it does such a bad job of explaining things that students are strongly encourage to spend more money on purchasing another book?

My initial experience was good and after a few weeks, my wife decided she liked what I was doing and decided she would also attend the University of Phoenix. My wife is legally blind which makes any schooling tough already. But many of the school's materials do not allow the use of custom browser colors and many pages have frames specifically sized so they do not fit on the screen and scroll bars are not present. My wife reported the accessibility problems and was basically told that the University of Phoenix does not actually make their own material and so nothing could be done. No one offered to take it to the vendor or get the material available for non-web page use. It took several e-mail and phone calls to even get her point across. The University of Phoenix's idea of ADA compliance is basically to make whatever concessions a doctor writes down as helpful or necessary. So my wife had to call her doctor (who luckily she has known all her life and he is very nice) and get a note written on official letter head stating basic things like not having timed tests.

The latest fiasco with my wife is that the financial aid office seems to be clueless. My wife is on her second financial adviser already. Apparently she had a student loan a number of years ago that was consolidated. The US Department of Education failed to do their job properly and my wife has a phantom student loan in default for zero dollars. Yes, you read that right. In default for zero dollars. I call it a phantom because only about a third of the US Department of Education employees can even find it. Most of them look for it for 30 minutes or more before apologizing profusely for not being able to help her. This problem has been preventing the University of Phoenix from allowing her to get a student loan even though she was initially approved for a student loan. Despite three letters from the US Department of Education saying there is no defaulted loan, the University of Phoenix still sees it in some database they check and refuses to allow the letter to override their database. Despite this set back, they have allowed my wife to attend 4 classes now with no payment at all and no end to this in sight. Today my wife got a phone call saying she had received VA Education benefits in 2008. First, neither one of us got VA Education benefits in 2008. Second, my wife has been legally blind since before she was old enough to drive. She has RP. She has never been in the military or even been affiliated with the military other than being married to me.

So don't go to the University of Phoenix and think real hard before you even go to college. It is generally more expensive than it is worth unless you go into a field that truly requires it (like R&D, Academia, or Engineering).

Thanks for reading.

Tuesday, August 31, 2010

Got a Flakey ISP?

Originally published 1/5/09 on my old blog.

Have you ever had an ISP that gave you flakey service at best but you really did not have many choices? I had that problem. I was a few thousand feet to far from the CO for DSL access and I can't go back to dial up speeds so I had Comcast's broadband internet. The only problem was that in my area, Comcast was up and down like a yo-yo. Almost literally.

Despite many calls to customer service and a new cable modem (both were theirs, not mine), the problems persisted. Then at one point I started getting the run around. I was told that upgrades were being done in my area and that the outages were caused by those upgrades. I was told that customer service would not help me because they did not have inside knowledge on the upgrade project. They only knew I was in an affected area.

For 3 months I got that answer. So I wrote a two simple batch files, let them run for a week, and then hit Comcast back with my log files.

@ECHO OFF
cd \
ECHO -------------------->>inetchk.log
date /t>>inetchk.log
time /t>>inetchk.log
ping -n 1 www.google.com>>inetchk.log
ping -n 1 www.yahoo.com>>inetchk.log
ping -n 1 www.foxnews.com>>inetchk.log
ping -n 1 www.comcast.net>>inetchk.log
ping -n 1 www.ci.grand-rapids.mi.us>>inetchk.log
tracert www.google.com>>inetchk.log
tracert www.comcast.com>>inetchk.log

I ran that batch file every 15 minutes using the Windows XP Task Scheduler. Anyone familiar with basic network troubleshooting will instantly recognize these commands. I am testing my Internet connectivity and writing the results to a log file called inetchk.

I ran the second batch file daily to archive my daily log files. That helped me stay organized.

@ECHO OFF
cd \
xcopy inetchk.log c:\inetchk\ /C
cd inetchk
ren inetchk.log inetchk%date:~4,2%-%date:~7,2%-%date:~10%.log
cd \
del inetchk.log

This moved the files into my archive folder and renamed them with the date in the file name. This ensures that I have no duplicate files and gives me an at a glance view of the log files I have.

I was then able to take those log files back to Comcast. Needless to say, Comcast customer service was very taken back by my preparedness and were themselves unprepared to deal with me. After two calls (one from me to them and one from them to me) I was able to get one of the engineers on the upgrade project dispatched to my house (of course that was another few days out).

When he tried to give me the same line about the upgrades causing the outages, I was able to show him exact dates and times of my outages. He then admitted that all the outages relating to the upgrades were overnight and my outages were not consistent with problems from the upgrades. A bunch of new cabling, a new cable modem, and "some adjustments" in the line later I was in a much better spot.

Obviously I had genuine issues or I would not have had the response from Comcast that I had. But their customer service would not take my word for it. I had to prove to them that I knew what I was talking about. I think that says a lot about Comcast's customer service as well.

Thanks for reading.

Thursday, August 26, 2010

BASH Scripting

Over the past few years I have maintained some Linux servers including but not limited to ESX. I have never had a formal Linux training so I have relied on self help tools. For the most part, the Linux GUI's I have dealt with (Gnome and Knoppix) are easy to get around in. But sometimes you just need a script. There seems to always come a point in time, if you administer a system for a while, when you need the same action repeated at regular intervals and scripting the solution just makes more sense than waking up every four hours to double click something.

I have found two great resources for this. The first one is the Bash Scripting Tutorial over at Linuxconfig.org. I don't think it is the greatest tutorial per-say (although it is a very good one) but it makes an excellent reference. I keep it bookmarked. The second one is BASH Programming by Mike G. I think this is a better tutorial from a real world perspective (as opposed to the academic pursuit) and it makes a great reference guide as well.

Between these two sites, I have never had to look elsewhere for BASH scripts yet. The only other things you need to do then is create a cron job (a scheduled task in Windows terminology). The best explanation I have found for making a cron job is "How to Create a Cron Job (Scheduled Task) for Your Website or Blog" by Christopher Heng. The article explains the cron scheduling in great detail and then provides numerous examples. It also explains how to implement the cron job once you have decided what you need and how to code the schedule.

Thanks for reading.

Tuesday, August 24, 2010

Information Gathering Prior to P2V's

Originally posted on my old blog on December 17, 2008.

Most recently I have been on a server consolidation project for a large company that is consolidating 40+ sites globally. This contract basically involves simply building hosts and performing P2V's using VMware Converter (or as it is now known, vCenter Converter stand alone). As anyone who has done a project on this scale knows, scripting makes long processes go flying by. So I thought I would give out a few juicy tidbits that I have been using.

By far, the P2V process is the most time consuming. So I wrote a few scripts.

The first step in any migration process is information gathering. You need to know the details of what you are going to migrate. I have two scripts in this category.

The first is to check credentials. Because this client is a very large company, there are various potential credentials that could be correct. We always ask the local site for the local administrator credentials but those don't necessarily work. They also have "global" local administrator credentials. So the first thing my script does is prompt you for the server and credentials.

"set /P Server=What is the name or IP of the server you want information on?:"
"net use \\%server%"

This checks the name resolution from the computer you are using to run the script from. If it fails, the script will stop and tell you. Then I move on to prompting for credentials.

"ECHO Are there custom credentials for this server?"
"choice"

Then using error level evaluation and GOTO statements, I go to the appropriate next section. I use the same method ("set /P") to establish any custom admin user names and passwords.

I then have a series of sections that look like this:

"ECHO Attempting the first password..."
"net use \\%server%\ /USER:%Server%\%CustUser% %CustPasswd1%"
"IF errorlevel 1 GOTO :Cust1b"
"ECHO These credentials worked for %SERVER%..."
"ECHO %Server%\%CustUser% %CustPasswd1%"
"GOTO :END"

":Cust1b" is the next section. So if the net use statement fails ("errorlevel 1"), the script skips to the next section. If the statement is successful (the unmentioned "errorlevel 0"), it prints those credentials back to you and skips to the ":END" section with ends with a "PAUSE". This allows the script to leave things on the screen for you so you have time to read and, more usefully, to copy (and paste into the next script which can be run while this window is still open).

Now you know if your credentials are valid and it only took as long as it took you to double click the script, enter the server, user name, and password. Once that is established, you can move on to actually gathering information.

I again start with "set /P" statement to establish the server and user information. In my information gathering script, I default to WMIC but also watch for errors. In critical sections (like the network settings and system information) I go back to using psexec and devcon to pass commands over to the server. This way I guarantee the script will gather the information.

The WMIC commands I use are like:
"%windir%\system32\wbem\wmic.exe /NODE:%Server% /USER:%User% /PASSWORD:%Password% os get description, manufacturer, name, version, servicepackmajorversion /FORMAT:CSV >> results_%Server%.csv"

This will write a csv file in the folder that the script was run from. This particular WMIC line will give me the Operating System name, version, and Service Pack level. Anyone who has done conversion before can tell you this information is critical for compatibility information and a heads up on what to expect.

I also run:

"wmic.exe nicconfig get description, dhcpenabled, dnshostname, dnsdomain, ipaddress, ipsubnet, defaultipgateway, dnsserversearchorder, dnsDomainSuffixSearchOrder, macaddress, winsPrimaryServer, winsSecondaryServer"

"wmic.exe computersystem get caption, description, domain, manufacturer, model, name, numberofprocessors, systemtype, totalphysicalmemory, username"

"wmic.exe logicaldisk get name, volumename, size, freespace, compressed, description, filesystem"

"wmic.exe product list brief"

These commands get me critical information regarding network setup, disk setup (size, format, compression, etc), and a list of software on the box. I have gotten mixed results with the software listing ("product list brief"). It also gets me some information that is just REALLY handy to have (like how much disk space is used).

If the "nicconfig" fails I use psexec to run an "ipconfig /all" command. If the "os" statement fails, I use psexec to initiate a "systeminfo" command.

Astute readers are probably starting to wonder what devcon is (if they don't already know) and what I use it for. I use devcon to get me the HAL information so I know if I will have to change it from a multi-processor to a uni-processor. Generally this is more of a "nice to know" than a necessity. But it is a contractual requirement for us to gather that information. I do that in the following code:

"net use \\%server% /USER:%User% %Password%"
"devcon -m:\\%Server% find *acpi_hal* >> results_%Server%.csv"
"net use /delete \\%server%"

The script itself is actually 173 lines long which is why I am not posting the entire script. But a lot of that is formatting (each section break in the results file is 6 lines worth of code and there is a break between each WMIC command) and error handling.

I did not write the script so I will not post any of the code here, but as a hint: the devcon utility is a MS published utility that can also be used to remove any non-present hardware devices.

Some of this might be done easier in VBS or similar except that I do not know VBS so I did it as a standard batch file. My VBS book is on my Christmas list ;-)

Thanks for reading.

Thursday, August 19, 2010

VM Heartbeat Status

I recently ran into a problem where the VM Heartbeat status alarm is triggered. The alarm clears itself if you restart the VMware Tools service or if you connect to the VM with the VIC console feature. You do not even have to put your mouse in the VM, let alone log in, to get the alarm to clear. According to this community thread it is a known issue. I did not see anything in the ESXi 4.1 release notes indicating a fix. I am seeing it on ESXi 4.0 Update 2.

For anyone experiencing this issue, I recommend reading the thread and then submitting a SR to VMware. That way priority can be given to fixing this bug.

Thanks for reading.