vbscript ping multiple hosts from windows and log in excel

We’ve been having lots of complaints about sketchy internet on the first floor. It’s always hard to quantify internet problems, is it bandwidth, poor wireless reception, bad AP/Wireless Card, someone complaining for fun, or an actual outage?

In an effort to diagnose it myself with the least amount of work possible I stumbled upon this VB Script which pings a host defined in a text document and outputs it to excel.

I hacked on it a little bit and came up with this:

vb script output

Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.Workbooks.Add
intRow = 2

Set Fso = CreateObject("Scripting.FileSystemObject")
Set InputFile = fso.OpenTextFile("list.txt")

count=0

Do While Not (InputFile.atEndOfStream)
	objExcel.Cells(1, 1+count).Value = "Machine Name"
	objExcel.Cells(1, 2+count).Value = "Results"
	count=count+2
	InputFile.ReadLine
Loop
objExcel.Cells(1, 1+count).Value = "Time"
objExcel.Cells(1, 2+count).Value = "Date"

Do While 1
	Set Fso = CreateObject("Scripting.FileSystemObject")
	Set InputFile = fso.OpenTextFile("list.txt")
	count=0

	Do While Not (InputFile.atEndOfStream)
		HostName = InputFile.ReadLine
		Set WshShell = WScript.CreateObject("WScript.Shell")
		Ping = WshShell.Run("ping -n 1 " & HostName, 0, True)
		objExcel.Cells(intRow, 1+count).Value = HostName
		Select Case Ping
		Case 0
			objExcel.Cells(intRow, 2+count).Value = "On Line"
			objExcel.Cells(intRow, 2+count).Interior.ColorIndex = 4
		Case 1
			objExcel.Cells(intRow, 2+count).Value = "Off Line"
			objExcel.Cells(intRow, 2+count).Interior.ColorIndex = 3
		End Select
		count=count+2
	Loop

	objExcel.Cells(intRow, 1+count).Value = TimeValue(Now())
	objExcel.Cells(intRow, 2+count).Value = date

	intRow = intRow + 1

	WScript.sleep 30000

	objExcel.Rows(1).Select
	objExcel.Selection.Interior.ColorIndex = 19
	objExcel.Selection.Font.ColorIndex = 11
	objExcel.Selection.Font.Bold = True
	objExcel.Cells.EntireColumn.AutoFit
Loop

All you have to do is create a text document “list.text” in the same directory as this vb script and it will layout the excel document for you without any modifications. Only thing you may want to change is the delay/sleep I put in on this line “WScript.sleep 30000″ which tells it to wait 30 seconds before continuing.

The best part is that I could feasibly give this to a non-technical tenant use it to troubleshoot their connection problems.
The host list would include something like their AP, the Gateway, google.com and another host thats known to be reliable to ping like 4.2.2.2

cabelas customer service is amazing

I placed an order at Cabela’s on Tuesday and after completion I didn’t receive an email. Normally I’d login to my account to check its status but since they gave me the option of not creating an account and thus not needing another password to remember I took it. (THANK YOU!)

To my amazement an actual person answered the phone after just 2 rings. In an age where EVERY company I deal with, both for work and in personal life, makes you navigate a phone menu maze it was astounding. I got my order confirmation number from the guy in under 1 minute. Just another reason Cabela’s is great and they’re earning a lifetime customer.

posterous rocks

A few weeks ago I had to setup a blog at work on short notice. Despite the fact that Drupal has pretty much all the blogging features we needed there’s some stigma around our website. The problem isn’t the website, it’s the content and its organization. However rather than try and explain that I elected to just find another solution.

The last thing I want to do is maintain another service, WordPress/Drupal/sharepoint/blah+blah all mean backups and security lists. So I advocated a hosted solution where I would only be responsible for some initial setup and training then it would be up to content people to do the content stuff. Which is really ~90% of the battle. Good content can overcome poor design, bad technology and terrible graphics.

Jason @ Pignite web design in Chehalis/Lacey/Olympia had told me about Posterous a few weeks before so I went downstairs to pay him a visit. After about 1 hour of nerd talk I was confident Posterous would be perfect. ~2 hours later and I had purchased a domain name from godaddy, setup an account and started hacking on one of the prebuilt themes to fit our red/black/white logo/website branding and we’re done. Presented it to a group the next day and people were generally satisfied. And there you have http://thefarmstand.org .

We still need some graphics done up but otherwise it’s mostly complete. A few of my coworkers also took some initiative and finished the site out by adding a list of contributors with profile pictures and bios.

SBS 2008 SQL Memory Usage

We’re having a custom app developed for us that was having some speed problems after the server had been up for a while. I downloaded Sysinternals Process Explorer http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx and started digging around for problems. (haven’t mastered performance monitor yet) Tip: if you hover over the sqlservr.exe in Process Explorer it will give you the instance name in a hover balloon so you know which one is eating up memory.

I found the SBSMonitoring instance of SQL using 1.2 GB ram. For an application that looks relatively simple that amount of ram consumption seemed too high. To fix the problem I did some digging and found these pages:

http://msdn.microsoft.com/en-us/library/ms178067.aspx
Use Performance Monitor to set the “correct” ram usage on the SQL Server instance by using  the SQLServer:Buffer Manager object. Or just guess randomly like me.

http://dogriley.blogspot.com/2005/08/sqlservrexe-high-memory-usage-for.html
Set the maximum ram though CMD prompt

If you’ve got SQLServer Management Studio installed you can do it though GUI instead of CMD.

Connect to the instance of SQL, in this case “ServerName\SBSMONITORING”
Right click the Database instance and select properties
Then click the Memory section and put in your “Maximum Server Memory” (I set mine to 100MB)

db_properties

db_memory

Since our staff uses sharepoint VERY little I decided to limit that instance to 500MB. Connecting to that with SSMS wasn’t as easy as the SBSMonitoring instance. If you type in “ServerName\MICROSOFT##SSEE” it doesn’t connect. However this text does work “\\.\pipe\mssql$microsoft##ssee\sql\query”

solar project

This is just notes for now, will turn into the real deal soon enough.

Update 2:

http://www.solarpowerrocks.com/washington/
(long winded and annoying, but has info on incentives)

http://solardat.uoregon.edu/NorthwestSolarResourceMaps.html
(PNW solar potential)

http://www.gaisma.com/en/location/lacey-washington.html
(Solar path diagram- they’re kinda hard to read, but that’s basically the path the sun follows across the sky from equinox to equinox.)

Update 1:

http://www.windsun.com/ChargeControls/ChargeCont.htm

http://www.youtube.com/watch?v=Tmb5MB9_TaM

Sun tracking solar panel w/ arduino
http://www.youtube.com/watch?v=ATnnMFO60y8

Arduino solar Tracker
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1224541956/9

http://www.batteryuniversity.com/partone-13.htm

http://www.discovercircuits.com/B/batt-chrg2.htm

Links:

How to make solar power generator

http://www.rain.org/~philfear/how2solar.html

Solar generator diagram

http://www.thefarm.org/charities/i4at/surv/solargen.htm

Optomize Panel w/ mirrors

http://www.thefarm.org/charities/i4at/surv/panplus.htm

Harbor freight solar panel demo

http://www.youtube.com/watch?v=caeEyhJZnTs

pt2

http://www.youtube.com/watch?v=N86eHRGRJwQ

Inverter:

http://www.lanescarproducts.com/225-watt-power-inverter-450-watt-peak.html

inverter faq:

http://www.donrowe.com/inverters/inverter_faq.html

What are amps, watts, volts and ohms?:

http://science.howstuffworks.com/question501.htm

DC Cabling Calculator:

http://www.energymatters.com.au/climate-data/cable-sizing-calculator.php

Connect Mac to Server 2008

Had problems connecting OSX 10.4.11 to our new 2008 Small Business Server. Lots of stuff on Google but no one place seemed to have the silver bullet so I turned to old reliable, the [H]Forums. Turns out you need to adjust some settings on the domain controller having to do with encryption.

Problem: Macs couldn’t access shares over SMB
Solution:

Group Policy Management > +Domains > +Domain.Name > +Domain Controllers > Right click Edit Default Domain Controllers Policy

+Policies > +Windows Settings > +Security Settings > +Local Policies > Click User Security Options

Microsoft network client: Digitally sign communications (if server agrees) : ENABLED
Microsoft network server: Digitally sign communications (always) : DISABLED
Microsoft network server: Digitally sign communications (if client agrees) : ENABLED

Start > Run > gpupdate /force (not sure if this step is needed)

exchange 2007 sending email from copier

So by default if you’re running a single server Exchange solution such as SBS then your server is configured not to accept “anonymous” connections. In other words, devices that aren’t authenticated with the domain can’t send email (with the exception of other Exchange servers. This will stop *nix boxes or multifunction devices like copiers from sending emails.

Run this command from the Exchange management shell to allow anonymous connections.

Set-ReceiveConnector -Identity “Default <insert server name>” -PermissionGroups “AnonymousUsers”

companyweb doesn’t work in firefox

I was trying to access the internal SharePoint site at work and kept getting authentication requests while in FireFox. Some googling turned up the following fix.

In the Firefox address bar type “about:config”
Locate the key called “network.automatic-ntlm-auth.trusted-uris”

Double click and put in a comma seperated list of all your internal sites. In this case I needed to add “companyweb” Didn’t even need a restart and FF no longer asks me for authentication to the SharePoint site

Freebsd Samba won’t start.. silly cups

I don’t provide any print services from my FreeBSD box. So when samba refused to start because of a cups connection problem I was pretty confused.

[user@test ]$ tail -f /var/log/samba/log.smbd

[2009/07/29 10:06:14, 0] printing/print_cups.c:cups_connect(69)
Unable to connect to CUPS server localhost:631 – Connection refused

After some google work I found this.

For those seeing the same error, it’s apparently solved by adding this
line to [global]:
printcap name = /etc/printcap

So a quick trip to “/usr/local/etc/smb.conf” and I uncomment:

;     printcap name = /etc/printcap

Then I start samba “/usr/local/sbin/smbd -D” and all is good in the world once again.

OpenAudit views

Working on my OpenAudit view.  Trying to get down to 1 report that I can use to prioritize software/hardware upgrade paths for all staff.

This test is just to pull out Office and Windows verision/keys. Not interested in extra stuff like Visio or Project right now since they’re special cases.

Had to do some hacking because even though only Outlook from SBS 2003 is installed on a few computers OpenAudit reads it as full Office 2003 messing up the reporting. To fix this on machines that had OEM Office 2000 installs that don’t register I added the search for ‘Microsoft Office Outlo’

SELECT s.net_user_name, s.system_name, m1.ms_keys_uuid,
if( left( m1.ms_keys_name, 22 ) = ‘Microsoft Office Outlo’, ‘n/a’, m1.ms_keys_name ) AS OfficeVersion,
if( left( m1.ms_keys_name, 22 ) = ‘Microsoft Office Outlo’, ‘n/a’, m1.ms_keys_cd_key ) AS OfficeKey,
m2.ms_keys_name as WindowsVersion, m2.ms_keys_cd_key as WindowsKey
FROM `system` AS s
INNER JOIN `ms_keys` AS m1 ON s.system_uuid = m1.ms_keys_uuid
LEFT JOIN `ms_keys` AS m2 ON m1.ms_keys_uuid = m2.ms_keys_uuid
WHERE left( m2.ms_keys_key_type, 6 ) = ‘window’
AND (left( m1.ms_keys_name, 22 ) = ‘Microsoft Office Profe’
OR left( m1.ms_keys_name, 22 ) = ‘Microsoft Office Small’
OR left( m1.ms_keys_name, 22 ) = ‘Microsoft Office Outlo’)
GROUP BY m1.ms_keys_uuid