Nigel Boulton's Blog
26Mar/110

Regular Expressions in PowerShell – Tome Tanasovski

Tome Tanasovski (@toenuff on Twitter) who runs the NYC PowerShell User Group did a brilliant presentation on Regular Expressions in PowerShell to the UK PowerShell User Group earlier this week - by far the best I've seen to date.

Richard Siddaway (who runs the UK PowerShell User Group) has kindly made the recording available here and Tome's presentation slides, scripts and cheat sheet here. Well worth a look!

Many thanks to Tome, and of course to Richard for organising this event.

Filed under: PowerShell No Comments
23Mar/115

On-Demand Access to your Windows Live SkyDrive via Windows Explorer

My eldest is off to University later this year, and I had suggested that he upload any important documents to his Windows Live SkyDrive, for online backup and the ability to edit them if necessary from any machine with a browser.

I thought it would be worth finding a slick way of giving access to the SkyDrive via a mapped drive in Windows Explorer, ideally connecting only when required and without the annoyance of being prompted for credentials – that way the backups are more likely to happen! I was aiming to do this using what Windows 7 has to offer natively and avoiding installing any additional applications.

A quick search led me to this great post from Mike Plate. This gave me a good starting point.

I had previously used the Office 2010 method that Mike describes to successfully determine the correct path to the "My Documents" folder on the SkyDrive, but I ran into an issue (discussed below), and it has to be said that this method is slightly convoluted. Fortunately, as described in the update to the above mentioned post, Mike has developed a neat tool called the SkyDrive Simple Viewer, which is available on CodePlex to assist with this. The EXE can be run from a folder on your PC and doesn’t require installation.

Here are the steps required - you will need to perform these logged on as the user who will use the mapped drive. At the end of this process you will have a nice desktop shortcut looking something like this, that you can double-click and have your SkyDrive folder silently mapped to a drive letter on your PC:

Update 10 Dec 2011: The SkyDrive Simple Viewer no longer seems to work correctly. Please see the comment below for details, and a link to an alternative method of determining the WebDAV address.

1. Download the SkyDrive Simple Viewer for WebDAV (I used the WPF version, which requires .Net Framework 3.5 SP1)

2. Run the viewer and log in to your SkyDrive using your Windows Live credentials, then select the top-level folder you want to use to store your documents in. If this is anything other than the default "My Documents" folder you will have to log on to your SkyDrive via a browser and create it using the normal method before doing this

3. Copy the WebDAV address from the text field in the viewer and paste this into a new Notepad document. It should look something like this:

https://yxbjla.docs.live.net/bc634a9b20da709c/^.Documents

In the above example, we’ll call "yxbjla.docs.live.net" the Server FQDN, "bc634a9b20da709c" the SkyDrive ID and "^.Documents" the Folder ID. Note that the Server FQDN will differ for each top-level folder on your SkyDrive

4. Edit the text document to create a new command line in the format shown below:

net use Drive Letter "\\Server FQDN@SSL\DavWWWRoot\SkyDrive ID\Folder ID" /SAVECRED /PERSISTENT:NO

e.g.

net use s: "\\[email protected]\DavWWWRoot\bc634a9b20da709c\^.Documents" /SAVECRED /PERSISTENT:NO

A few key points here – I mentioned above that I’d run into an issue when following Mike’s article. Well, this was when attempting to map a drive to the default SkyDrive "My Documents" folder. For me, it is identified by WebDAV (as can be seen above) as "^.Documents", not "^2Documents" (perhaps Microsoft have changed this since Mike wrote his article?). Anyway, I was able to map the drive using "^.Documents", but ran into access denied errors copying files onto the SkyDrive via that route. To address this, I found that I had to enclose the entire WebDAV path in quotes, as shown in the command line above

The key to not being prompted to log on each time is to have Windows store your Windows Live credentials for you – the /SAVECRED switch does this, and the /PERSISTENT:NO switch avoids Windows mapping the drive at each logon, so that it can be done "on demand"

5. Open a Command Prompt and paste the command line you created in the Notepad document in after the prompt, and then press Enter. When prompted, provide your user name and password (i.e. your Windows Live credentials) and you should see the message "The command completed successfully". A quick check in Computer should show that the drive is mapped and the files on your SkyDrive are accessible

6. Right-click the mapped drive and select Disconnect

Finally, we need to create a shortcut to map the drive when desired:

7. Right-click the desktop and create a new shortcut

8. Paste the command line you created in the text document into the wizard without the switches, e.g.

net use s: "\\[email protected]\DavWWWRoot\bc634a9b20da709c\^.Documents"

9. Give the shortcut a suitable name (bearing in mind you can’t use a colon (:) in the name of the shortcut), and save it

10. Finally, edit the shortcut properties to run it minimised, and select a suitable icon using the Change Icon button

I selected an icon from SHELL32.dll – there’s a good number in there to choose from. Mine shows a couple of computers with a network connection alongside a globe, which I think sums up the function nicely!

11. If you would like a new Windows Explorer window to open displaying the contents of the SkyDrive folder after mapping the drive, edit the shortcut properties to prefix the target with "cmd /c " and append " & explorer s:", (without the quotes) as shown below:

cmd /c net use s: "\\[email protected]\DavWWWRoot\bc634a9b20da709c\^.Documents" & explorer s:

I find managing files on the SkyDrive this way works well, and you can go ahead and create subfolders at will using the normal Windows methods. However, if you need access to a different top-level folder you will need to set up an alternative shortcut (and/or drive letter) by following the steps above again.

If you change your Windows Live password in future, it will be necessary to repeat the steps above up to the point where you create the shortcut, to provide and save the new credentials. There isn’t a documented method of permanently removing the saved credentials should they no longer be required, as far as I’m aware - however, I will mention that they are stored under %APPDATA%\Microsoft\Credentials in hidden system files – delete them (and reboot) at your own risk!

I have seen it reported that accessing files on your SkyDrive via WebDAV can be very slow, but I haven’t experienced this myself. Of course you must remember that there is no way that it’s likely to be comparable to local storage or LAN speed-wise. Various people have reported that ensuring you do not have your Internet Explorer proxy settings configured for automatic detection can improve transfer speeds – I haven’t tested this myself. To check this, in Internet Explorer, go to Tools – Internet Options – Connections tab – LAN settings and ensure that the "Automatically detect settings" checkbox is unselected (assuming you don’t need to use this functionality of course).

Bear in mind that all the usual restrictions with regard to your SkyDrive still apply – you can only upload files of up to 50 MB in size each, and only certain types of files are permitted. However, with 25 GB of storage provided by Microsoft for free, this is a convenient way to store (and edit) your important Office documents online.

Finally, if you’d like to do this without the complication and you’re happy to install additional applications, there are a number of free applications available that may meet your needs. In the course of this work I tested a few of them, but none of them provided exactly what I wanted, so I stuck with the method described in this post.

Filed under: Windows 5 Comments