Using relative paths to source for the Web Deploy tool (msdeploy.exe)

A colleague of mine recently wanted to write a script employing MSDeploy. Understandably he wanted to make the deployment scripts portable so that they could be used on different machines without forcing the deployment from and to the same directories on the different machines. Simple he thought: relative paths. I would have thought the same thing.

He expected to do something like the following (shortened for illustrative purposes):

msdeploy.exe -source:contentPath=".\SourceDir"

Simple until you discover that the tool requires either absolute paths or a full site/application path. This is clearly documented here. This documentation states that environment variables can be used and names %WINDIR% as an example.

The simplicity of the solution (also discovered by my colleague) was to delve back into DOS scripting days and use %CD%. This is the environment variable for the current directory. (Typing the quotes as well) try "%CD%" on the command line and see what you get. Just what you want for:

msdeploy.exe -source:contentPath="%CD%\SourceDir"

Locating stored procedures (and more) on a SQL Server instance.

Sometimes you need to locate a stored procedure on a SQL Server instance but you are not sure what database it is in. Well, at least I sometimes find myself in that situation. The following script iterates over each of the databases on the current SQL Server instance displaying the database name which contains the stored procedure named (replace #Stored Procedure Name# with the name of the stored procedure you are looking for):

-- Use for stored procedures only.
'USE [?];
DECLARE @databaseName VARCHAR(100);
WHERE ROUTINE_NAME = ''#Stored Procedure Name#''
IF @databaseName IS NOT NULL PRINT @databaseName'

Sometimes you know only part of it so the following script uses the LIKE statement which uses % as a wildcard. This can be used wherever the LIKE statement allows (see For example:

'USE [?];
DECLARE @databaseName VARCHAR(100);
USE [?]; SELECT @databaseName = ''?'' FROM sys.sysobjects
WHERE LIKE ''#Start Of Stored Procedure Name#%''
AND sys.sysobjects.type = ''P''
IF @databaseName IS NOT NULL PRINT @databaseName'

If you want to search for other object types then you need to replace the value compared to sys.sysobjects.type from P to one of the following:

AF = Aggregate function (CLR)
C = CHECK constraint
D = Default or DEFAULT constraint
F = FOREIGN KEY constraint
FN = Scalar function
FS = Assembly (CLR) scalar-function
FT = Assembly (CLR) table-valued functionIF = In-lined table-function
IT - Internal table
K = PRIMARY KEY or UNIQUE constraint
L = Log
P = Stored procedure
PC = Assembly (CLR) stored-procedure
R = Rule
RF = Replication filter stored procedure
S = System table
SN = Synonym
SQ = Service queue
TA = Assembly (CLR) DML trigger
TF = Table function
TR = SQL DML Trigger
TT = Table type
U = User table
V = View
X = Extended stored procedure

This was sourced from the MSDN article for sys.sysobjects (

Unsubscribing from Apple’s MobileMe Trial

So my better half wanted to unsubscribe from Apple’s MobileMe after an unsuccessful trial. What that really means, to be totally fair to both Apple and myself, is that MobileMe didn’t meet her requirements and that I was to unsubscribe from it for her (after all I had help her set it up in the first place).

This should have been a simple 5 minute task at most. IT WAS NOT!!! (No, CAPS LOCK was not accidentally pressed. Yes, I am cross).

As an existing iTunes user, my wife has long had an Apple account. For the purposes I shall refer to it as

During setup of the MobileMe trial my wife used her existing Apple ID and was issued a new email address for MobileMe which I shall refer to

My wife was sent the following in an email from the MobileMe service which hit her one and only inbox:

If you’d like to make changes to the billing settings listed, log into and click on Account. Choose Account Options to cancel your account, or Billing Info to update your credit card.

I clicked the link and entered her Apple ID ( which sent me straight to the rather good Find page which proceeded to locate and display the two devices she had registered. There was a menu with a dropdown list with Account. Which I clicked. This opened up a new page which, after re-authentication, gave access to her Apple ID account details.

All good so far except that there was no mention of MobileMe.

After a bit of digging I found a thread on Apple’s own Apple Support Communities forums. This lead me to an Apple Knowledge Base article. Which suggested the link again.

By now I felt that I was going around in circles. I cannot tell you how many times I clicked a link then authenticated only to be on the Find page again. Yes, the only functionality I could find on MobileMe was the Find page!!!

Solution Found

It then struck me that I had this MobileMe email address. It turns out that I had to log in with that email address to access the MobileMe account details. Ironically, it said that it had no associated devices. At least it did allow me to cancel the subscription.

I cannot work out whether it was me or Apple. Should I have remembered to log in with this issued email address? Probably? Should MobileMe have allowed use of an existing Apple ID? Probably. Should Apple have reminded people that this login might use different credentials from their Apple ID that is used for other Apple services? I think so.

How to backup your Google Calendar automatically on a Windows machine

This is a quick and brief example of how to schedule a backup of a Google Calendar on a Windows machine. This technique uses a PowerShell script and the Windows Scheduler.

First you need to get the information required from Google:

  1. Login to Google Calendar.
  2. Under “My Calendars” click the down arrow (outlined in red in the pic below) that’s at the right of the name of your main calendar, the one you want to backup.

Google Calendar Settings

  1. Then click “Calendar settings”.
  2. In the view that appears, scroll down to the bottom, and find the bit headed “Private Address”, see below.

Google Calendar Right Click Position

  1. Right click the green ICAL button under “Private Address”, which provides the URL or web address of your own calendar file which will be something like (NOTE: keep this address to yourself).

Next create a PowerShell script:

The following should be saved in a file (this will use the example file C:\GoogleCalendarBackup.ps1) where the $Source is set to the “Private Address” URL retreived above:

$WebClient = New-Object System.Net.WebClient
$source = ""
$target = "C:\GoogleCalendarBackup.ics"
$WebClient.DownloadFile($source, $target)

Finally create the scheduled task:

  1. Open Start Menu\All Programs\Accesssories\System Tools\Task Scheduler
  2. Select Action\Create Basic Task…
  3. Enter a name and (optionally) a description then press Next.
  4. Select the frequency of the backup and press Next.
  5. Select the details of the backup frequency and press Next.
  6. Select “Start a program” for the Action and press Next.
  7. Browse to the PowerShell executable on your machine e.g. C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe.
  8. Put -nologo -command “& {C:\GoogleCalendarBackup.ps1}” in the Add Arguments box and click Next.
  9. Review your setting and click Finish.

I ran the scheduled task to ensure that the backup worked then checked that the scheduled task is running for the first few times just to be sure.

NOTE: Retrieving the Google Calendar URL is based upon by Improbulus

Many thanks to Improbulus.


Get every new post delivered to your Inbox.