Archive for Scripts & Utilities

We’ve been using the Linksys SPA942 handsets for a while and they have worked very well for us. One of the major annoyances for us and others is the inability to populate the personal directory automatically.

I’ve read a number of posts on how to use wget to issue to personal directory to the phone via a HTTP post and this seemed like a good solution. In particular this post and this post inspired me to see if I could create a solution using the same technique in VB.Net.

So I have put together a simple program which will allow you to load/save a personal directory to/from a tab delimited file or handset. There are loads of enhancements that could be made in order to make the application more sophisticated but this is really a first attempt, so please report any problems.  You will need .net framework 3.0 to run the tool.  I’ll put the project into a proper setup file if it is sufficiently popular.

Here is a screenshot of the utility:

Download here:

SPA 942 Personal Directory Manager

I’m using firmware version 6.1.5a, I’d be interested to hear if this does/does not work on other versions or if anyone has any suggestions for enhancements.

This is also a great way to backup/restore your Linksys SPA handset – I factory reset my handset and this much easier than re-entering all the personal directory.

Categories : Scripts & Utilities
Comments (9)

This is a script that I posted to the Draytek forum a couple of years ago, I noticed that it has been a very popular post so I have decided to post here also.

The function of the script is to perform scheduled reboots of Draytek routers.  Optionally is it possible to reboot the router only if a specified IP address does not respond to a ping request.  This is useful to test if a VPN connection is functioning, and only reboot the router if there is no response.

Early Draytek firmwares had a tendancy to lose VPN connectivity and a reboot is the only way to restore the connection.

First of you need to install the Toolsack Baseline components for this script to work:

http://www.toolsack.com/download/

The script needs to be supplied with parameters, so a typical command line would look like this:

cscript reboot.vbs 86.11.93.131 routerpassword

and a conditional command line would look like this:

cscript reboot.vbs 86.11.93.131 routerpassword 192.168.1.254

The 3rd argument will be tested for a ping response, if none is received then a reboot will be executed.

Here is the code, save it as reboot.vbs:

set args=wscript.arguments

If wscript.arguments.count=2 then
   IP=args.item(0)
   Password=args.item(1)
   call reboot(IP,Password)
elseif wscript.arguments.count=3 then
   IP=args.item(0)
   Password=args.item(1)
   TestIP=args.item(2)
   if ping(TestIP)=False then
      call reboot(IP,Password)
   end if
else
   wscript.echo "Invalid number of arguments specified"
   wscript.echo "Please specify router IP address & password and optional test IP"
end if

sub reboot(IP, Password)
   set s = CreateObject("Toolsack.Socket")
   s.Connect IP, 23
       s.Write Password & vbCrLf
   s.write "sys reboot" & vbcrlf
   s.write "quit" & vbcrlf
end sub

Function Ping(strHost)

    dim objPing, objRetStatus

    set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery _
      ("select * from Win32_PingStatus where address = '" & strHost & "'")

    for each objRetStatus in objPing
        if IsNull(objRetStatus.StatusCode) or objRetStatus.StatusCode<>0 then
       Ping = False
        else
            Ping = True
        end if
    next
End Function 
Comments (0)

I am always forgetting the syntax for the New-ExchangeCertificate cmdlet when I need to do a new certificate request so I decided to write a little bit of javascript to build up the command automatically. Its much easier to copy and paste it from here than work with in it the Exchange 2007 Command Shell.

So just fill in the fields below and the command will be built automatically in the box below. Then just copy into command shell. If required, seperate the “Subject Alternative Names” with commas.

Common Name:

Subject Alternative Names:
Organisation:
Organisational Unit:
Town/City:
County/State:
Country:

CSR Command:

I am thinking of duplicating this code and writing another post which will generate the commands for the import of the newly generated certificate.

Comments (1)

Dell Openmanage Server Administrator is a really useful tool for configuring and monitoring server hardware but it lacks built in E-Mail alerting or notifications.

The software is capable of calling external programs or scripts when a server alert is triggered so I have written a simple script that provides E-Mail alert functionality.

There are a couple of scripts out there that do similar, but I wanted something self contained and capable of using SMTP Authentication with an external relay.

The other problem with OMSA is that you need to go into each individual alert to configure the settings which can be very time consuming, I wanted a way to add them all automatically as I am going to install the script on a number of servers.

Install the script by extracting the DellAlert.Vbs script file from this zip file:

Dell OMSA E-Mail Alerts

Once you have extracted the zip file you will need to edit the variables at the top of the script to make them appropriate for your environment:

The variables at the top define the e-mail settings and are hopefully self explanatory. If a remote SMTP server is not specified the local machine will be used to send the E-Mail.

Below these you can to decide what events you want to be notified of, just comment out any that you aren’t interested in, e.g:

AlertConfig(0)="powersupply|Power supply failure"
AlertConfig(1)="powersupplywarn|Power supply warning"
'AlertConfig(2)="tempwarn|Temperature warning"
'AlertConfig(3)="tempfail|Temperature failure"

I have included every alert available in OMSA 6.2 on a PE T710, some of these alerts won’t be available on older versions or machines.

After you have configured the script, I suggest you test that the E-Mail options by running:

cscript dellalert.vbs testemail

You should receive a test e-mail, if not something isn’t working properly.

When you have successfully tested e-mail, configure OMSA to send alerts by running:

cscript dellalert.vbs setup

You will then see the script go through and setup all the appropriate alerts as per your settings. This process can take a couple of minutes as the “omconfig” command takes a while. This step will not work if you do not have OMSA installed.

Once this is done you should be able to see that the script has been added into OMSA:

Now you need to generate some real alerts to test the script properly. How you do this will depend on the capabilities of your server, I was able to disconnect the redundant power supply and have an alert generated almost immediately. I think opening the case will also generate an event, but I am not sure as I didn’t test. Hopefully you should get something like this in your Inbox:

I have installed this on a few servers and it seems to be working well. I will update the script with any tweaks that I add as I roll it out further. Hope this is useful to someone else.

If you are using Exchange 2007…..

This script will not work properly until you register the 32-Bit version of cdo.dll.  Follow the instructions for doing this here:

http://blogs.msdn.com/mstehle/archive/2007/12/11/fyi-after-installing-exchange-2007-sp1-32-bit-cdosys-might-not-be-registered.aspx

Oct
15

Sending backup tape reminder e-mails

Posted by: Paulie | Comments (3)

This is just a very quick script written in response to a question posted in one of the SBS yahoo groups.

It sends an e-mail to a specified recipient reminding them to change the backup tape in a server. The SBS backup system does this automatically, so this is meant for use on SBS servers using something other than the in-built SBS backup.

Installation is simply a case of extracting the contents of this zip file to a folder on your SBS server and then changing the variables at the top of the script to appropriate values for your environment.

Once done you can test interactively from a command line by running “cscript tapereminder.vbs” and once you are happy with the results setup a scheduled task to do the job daily.

Comments (3)

As the number of servers that I am responsible for managing increases, it becomes more difficult to ensure that they are all patched up to date.

As most of the machines I manage are SBS boxes I thought that it would be nice to put something together which behaves in much the same way as the SBS generated e-mail alerts.

So, the result is a script which sends e-mail notifications to a specified address and gives details of which patches are available to be installed.  The administrator can choose which of the four patch levels will trigger an e-mail alert (Critical, Important, Moderate & Low).

If there are no outstanding patches at the appropriate alert levels to be installed then the script will quit without sending an e-mail.

The script is then run as a scheduled task every evening and I can quickly see if I have anything to action.  The report includes links to the relevant KB articles and further information made available by Microsoft.

AutoUpdate

The script only takes a couple of minutes to setup as there are only six settings at the top of the file…

Setting any of the following to 1 will generate trigger alerts for that particular update severity:

  • AlertCritical
  • AlertImportant
  • AlertModerate 
  • AlertLow
  • EmailFrom – Specifies the e-mail address the report will be sent from.
  • EmailTo – Specifies the e-mail address to send the reports to.

variables

As shown above I have been running with AlertCritical/AlertImportant set to 1 and the other two set to 0. 

So, if you want to receive email alerts all you need to do is download this Zip file, extract the contents to a folder on your server and then edit the variables at the top of the script.  To perform a test run go into a command prompt and change directory to the location where you extracted the script and run:

cscript winupdates.vbs

With any luck you should get an e-mail soon after with the results.  If you find that it is not generating you an e-mail as expected, one reason may be that there are no patches available to install.  Bear in mind that not all items from Windows update will appear.  For example “Internet Explorer 7″ is not a patch and therefore will not be listed.

Running the script interactively as above will take a few moments while Windows Update(or WSUS if you have it installed) are checked for new updates. 

Once you have completed a successful test you can go ahead and setup a scheduled task.  Assuming an installation directory of “c:\scripts” the scheduled task command should look something like this:

C:\WINDOWS\system32\cscript.exe c:\scripts\winupdates.vbs

Also worth a mention that I have used this on standard(non-sbs) Windows servers and it works well.

Perhaps if enough people use this script, it will actually save as much time as it took to make it, but I doubt it. :)

Comments (14)