PowerShell: Start all VMWare services, self elevate to admin

For reasons, all my VMWare services are set to manual startup.  I like it this way.

I wanted an easy way to start all the services so naturally, a PowerShell script was required.  However the services can’t be started by PowerShell without elevated privileges, and I usually work in a non-elevated ISE.  So this version of the script self-elevates, saving me precious seconds.





PowerShell: JIRA Archiver v3

This web scraper is a little odd because it had to run within a very constrained environment.

Essentially it attempts to load URLs consisting of a prefix and sequential numerical suffix in the format;


then prints the webpage to PDF via the default printer, and downloads a zip file from the URL found in each page’s ‘aszip’ element.



ideas are in and of themselves worthless

A very good friend said to me once, and i’m paraphrasing for brevity,

“…ideas are worthless, they are everywhere, they are free.  It’s the ability to get them done that has any value.”

I’ve met plenty of people with good ideas.  People who can drive a good idea home to delivery are, however, of much rarer occurrence.



PowerShell: some simple snippets

Some simple PowerShell snippets I find useful.

Not worthy of their own pages, but useful nevertheless.

Show the start time of process

Search inside a set of files for a string






PowerShell: RoboClicky V2 Mouse Move, Click, Screen Capture

This script does a few things.  I will break it apart into separate posts that deal with each bit, but for now here is the whole lot.

The purpose of this script is to;

  • move the mouse to specific screen coordinates
  • click mouse buttons at those coordinates in order to drive an application
  • give the application time to respond
  • take a screenshot
  • save the screenshot as required
  • cater for multiple screens in a horizontal configuration

There are some functions in this one not specifically related to the objectives, but for reasons I won’t go into here, I generally try to keep all scripts as self-contained as possible.  I will try to break this out when I get time.










PowerShell: DVD copy automation script V2.0


I have a bunch of DVD’s that I want to archive to hard-disk so I can dispose of the DVDs.

Automate the process as much as possible.

Note: This is not a DVD copy protection crack, the DVD’s have to be copyable by the OS.


This script will wait for the DVD volume name to be NOT NULL

When a DVD is inserted, the script automatically creates a new folder in the destination root path, using the DVD name as the destination folder name.

After completing the copy it ejects the DVD drive and loops back into the waiting state.


  • Disk insertion detection (not based on auto-run)
  • Destination folder name duplication protection via folder-name suffix (this prevents DVDs of the same name overwriting each-other)
  • Simple copy integrity check using source and destination length comparison
  • Speech so I can hear it from the next room when the DVD needs to be changed out

To Do

I’m wondering if using  [System.IO.StreamWriter would be faster, but I think the bottleneck would be in the DVD Read, not the disk write.  Speculation only.  Next time I use the script I’ll make that modification and see how it goes.


My scripts are open source, free to use, come with neither warranty as to optimal performance nor suggestion that they are necessarily the best way to achieve anything.



Open Sourcing – all my code is belong to you!

Version 0.1


I first learned to code in ZX Spectrum BASIC at around the age of 10.  It was 1986.  More accurately, I learned to type and eventually understand the code from various ‘program your own games’ books and ‘Sinclair User’ magazine articles.

It was a little later that I actually achieved an understanding of the primitive building blocks of the code.

Quite possibly my young brain was prepped for the logic and structure of programming through my obsession with the essentially ‘if-then-else’ based Fighting Fantasy series of ‘choose your own adventure’ game books.

‘The Warlock of Firetop Mountain’ was the first I remember owning, and I believe the first in the series. They were awesome.  My very early unguided ventures into coding my own programs were literally codifications of these simple narratives.

I, like many people, have learned a lot of what I know about coding from commercially driven ‘pay for knowledge’ sources such as at university, training courses, and books. However, I am just old enough to claim some memory of the relatively early years of open source code sharing.

So, like everybody, I have also learned a stack from the open source information made available by the generosity, or naivety, nevertheless sheer enjoyment of sharing through magazines, blogs,  websites, friends and various other mediums.

So, I have decided to dig up and throw into the pot of shared online code, a bunch of my own work; better or poorer to be debated, but certainly useful.

Note: I don’t claim that any of this code still works, nor either that that which does, is optimal for the task.  Much of it is old, some of it is new, the context and constraints of the environment it was written for are here absent, but it all served a purpose.



[ 6 x 9 = 42 ] How six times nine equals forty two, and why it is the most powerful formula in the universe!

Six times nine equals forty two.  This is a cultural and mathematical certainty.

But it doesn’t … does it?  Yes it does!

Understanding how this apparent aberration of mathematics works can unlock the secrets of life, work, relationships, business, and, you know, everything.

So don’t panic!  Grab a cup of tea, find your towel, and prepare to disrupt your universe.

Why forty two?

Forty two is a very important number.

In fact, it’s not just a number.  It is the answer.  The ultimate answer.  The answer to life the universe and everything.

Continue reading [ 6 x 9 = 42 ] How six times nine equals forty two, and why it is the most powerful formula in the universe!


PowerShell Persistent eMail Sender – PixSeeMailR

The Problem

I have a number of scheduled PowerShell scripts that perform various system health checks.  If any of them detect something is amiss they send an alert email to myself and my support group using the send-mailmessage cmdlet.

However if the mail server was inaccessible when attempting to send-mailmessage, the command and resulting alert messages would fail.  This was a probable scenario given that the purpose of the error checking scripts is to detect problems including the inaccessibility of network resources.

So I wanted to easily add a level of persistence to the error message emails without having to require the individual health check scripts run continuously.

My solution was to have the checking scrpits place email details into an xml file, and have a batch emailing script pickup and send those messages when it could connect to the mail server.


I considered installing a local SMTP mail server such as hMail, and just let it relay through the corporate SMTP server.  However;

  1. I didn’t want to introduce new software to the server, and even though hMail is relatively simple, even it is seems like overkill for the requirement.
  2. I didn’t think the corporate security guys would appreciate me installing an SMTP server on the network.
  3. Most importantly, I felt like stretching my brain doing some PowerShell problem solving.

So I thought a PowerShell only solution would  be nice.

The Solution

Rather than have all my PowerShell scripts handle emailing I decided to create a simple email handling script I called PixSeeMailR.  (The name makes sense to me in the suite of scripts for which it is used.  See my article PixSeeLog: Error detection through image pixel inspection.)

The various other monitoring scripts create email messages (PowerShell objects that contain all the relevant message parameters) and deposit them into an “Out-Mail” folder as an XML file.

Messages in the Out-Mail folder are processed by PixSeeMailR periodically and moved to a “Sent-Mail” folder when they have been processed.  If the message processing fails for any number of reasons, the messages remain in the Out-Mail folder to be processed in the next period.

This solution design uses a scheduled PowerShell script to check for messages.  I also did consider using the System.IO.FileSystemWatcher to trigger the processing of messages as soon as they were deposited into the Out-Mail folder.  That would require the script to run persistently however and for this exercise I wanted to rely on scheduled script execution.

The following diagram shows how the process will work.

PowerShell Persistent Email Sender

Step 1 – Create Message

The first part of the solution is to create messages.

The following code creates message files by storing all the email message parameters into a PowerShell object and exporting that object to an XML file with Export-Clixml.

I use a message naming convention that guarantees (probably) unique message names.

This Create Message code can be added to any PowerShell script and activated according to whatever criteria is relevant.

Step 2 – Check For and Send Messages

The following code is designed to be run as a scheduled task.  I run it every 60 seconds, but you could run it at whatever frequency you like.

  1. The code performs the following steps:
  2. Check if there are any emails to send
  3. Check if the mail server is accessible
  4. Attempt to send each email
  5. Move sent emails to the ‘Sent’ folder
  6. Any messages that were unable to send successfully remain in the ‘Out’ folder and have their Attempts attribute incremented.



The solution presented here relies on two success testing methods.

1 – A simple TestNet-Connection against the target SMTP server.  If the server is not available the messages don’t attempt to send.

2 – The success or failure of the Send-MailMessage cmdlet.  If the cmdlet returns any error, the message is flagged for retry.

This approach doesn’t guarantee that the messages will reach the intended recipient, only that the SMTP server accepted the messages without error.

Future Upgrade Ideas

Next, I would like to implement the following upgrades;

  1. Turn the PixSeeMailR into a Windows service.
  2. Consider using System.IO.FileSystemWatcher to trigger mail sends immediately.


PixSeeMailR has been running on several of my servers for the past few days and seems to be working well.  I have scheduled a daily test message drop for 10 am every day and so far they have been processed as expected.

The average run time when there are no messages is 00.025 seconds.