solving sql server problems for millions of dbas and developers since 2006


Identify and resolve SQL Server problems BEFORE they happen with SQL diagnostic manager

SQL Server DBA Tips SQL Server Developer Tips SQL Server Business Intelligence Tips SQL Server Career Tips SQL Server Whitepapers SQL Server Tools SQL Server Webcasts SQL Server Questions and Answers SQL Server Questions and Answers









Simple Way to Download SQL Denali CTP3 VM from Microsoft using PowerShell

By: | Read Comments (4) | Print

Aaron is a Senior SQL Server Architect with over 10 years experience in architecture, BI, development and tuning.

Related Tips: More

Problem

A Community Technology Preview (CTP) is a great thing.  It allows you to explore an upcoming release and gives you an opportunity to provide early feedback to the development team.  CTP3 for the next edition of SQL Server, code-named Denali, was recently released.  Now, before you go installing this on a critical server for evaluation, you might think about the risks involved with a CTP.  It's not production-ready.  It's still being tested.  It might crash.  So, the best and easiest way to run your current version of SQL Server and Denali at the same time is to use a Virtual Machine.  Microsoft has recognized that this approach is a solid one, and has done us all the favor of creating a Hyper-V image of SQL Server Denali CTP3 at http://www.microsoft.com/download/en/details.aspx?id=27740

The only problem with the implementation of this idea is that the VM image is split into 36 individual files to "simplify the download".  I don’t know about you, but the last thing I want to do with my day is download each individual file manually. 

Solution

Enter PowerShell.  As some of you may remember, I published a script to download the MCM Videos that the good folks at SQLskills.com put together a while back.  Here, we'll be using the same concept and much of the same code to download all 36 pieces of the Hyper-V image of Denali CTP3.  However, this version has been enhanced to leverage the BITS built into Windows 7.  Note: If you’re on XP, I'm sorry but this script probably isn't going to work for you.  If you desperately want an XP version, let me know and I'll see what I can do.

First, the script will download the text of the page.  Then, it will read the entire download page, looking for a common RegEx match on file name.  In this case, it's looking for "SQLServerCodeNameDenaliCTP3".  If you download the PowerShell script, you'll see this being set to a variable named $FindThis.

One nice piece of functionality, considering the size of the download, is that the script will check to see if the file already exists.  If you're looking at the script, look for:  if ((Test-Path $file) -eq "true").  This is testing to see if the contents of the $file variable already exist.  If so, it'll skip over it, meaning you can stop and restart this download.  Also, there will be two progress windows when you execute the script.  The first is a progress bar for the file that is downloading, inspired by and heavily borrowed from PowerShell MVP Marco Shaw's ( blog | twitter ) fabulous script for downloading the videos from TechEd.  The second progress bar gives overall progress, telling you which file you're downloading.

What it will look like when this script is running.

To run this script launch PowerShell ISE and copy the PowerShell script from below or download it here. Then paste it into a PowerShell window and press F5 to execute the script and the download will begin.  Note that the default folder for the download is "C:\temp\", but this can be changed in the script if needed.

$Feed = (new-object net.webclient).DownloadString(“http://www.microsoft.com/download/en/details.aspx?id=27740”)            
$regex = "http://download.microsoft.com/download/./././[0-f]{8}-[0-f]{4}-[0-f]{4}-[0-f]{4}-[0-f]{12}/SQLServerCodeNameDenaliCTP3.part[0-9]{2}[^>]*?(rar|exe)"            
$MatchResults=[regex]::Matches($Feed, "$regex")            
$FileNamesFound = $MatchResults | % { $_.Value }            
            
Import-Module -Name BitsTransfer            
            
$script:total_sessions = $Null;            
foreach($session in $($FileNamesFound)) { $script:total_sessions++ }             
$script:current_session=1            
            
            
$FindThis = "SQLServerCodeNameDenaliCTP3"            
foreach($Vidlnk in $FileNamesFound)            
{            
Write-Progress -Activity "Overall progress" -Status $([string]$script:current_session+" of "+[string]$script:total_sessions) -PercentComplete $((${script:current_session}/$script:total_sessions)*100)             
$FileSplit=$Vidlnk -Split "$FindThis"            
$VideoName="$FindThis$($FileSplit[1])"            
$file="C:\temp\$VideoName"            
"Checking to see if $file has already been downloaded";            
if ((Test-Path $file) -eq "true") {"$file is already there mate"}            
else { "Downloading $file"            
Start-BitsTransfer -Source $Vidlnk -Destination $file }            
$script:current_session++             
}            

Once you get all of the files downloaded, you'll still need to reconstitute the Virtual Machine.  Look to the instructions at the bottom of the download page to get some guidance there.

Now, this is a pretty quick and dirty script.  I hope that it helps you download the image of Denali CTP3 more efficiently, but I'm also going to throw out the standard caveat.  No guarantees, no refunds, no returns.  Enjoy!

Next Steps



Related Tips: More | Become a paid author


Last Update: 11/2/2011

Share: Share 






Comments and Feedback:

Wednesday, November 02, 2011 - 10:42:10 AM - John Holt read the tip flag as SPAM

Good PS script.  It looks like this would really be a pain without it.


Friday, November 04, 2011 - 6:13:09 PM - Ken read the tip flag as SPAM

It's certainly fun to write scripts to do repetitive tasks like this.  However, you could also have just used a download manager like Free Download Manager.  Just highlight all 36 links, right click on it and select "Download Selected with Free Download Manager".  And you will get all 36 files downloaded.


Saturday, February 18, 2012 - 3:36:08 AM - Aditya read the tip flag as SPAM
Hi Michael, tnahks for the nice post.Is it necessary to add SQLEXPRESS in add connection, if I have SQL express and SQL Server 2008, and I am using SQL Server 2008 in add connection will it create any problem?

Tuesday, February 21, 2012 - 2:16:10 PM - mssqldude read the tip flag as SPAM

You'll need your scripts again if you want to go and download the new SQL Server 2012 RC0 set of industry BI demos which Microsoft just published with 42 compressed files: http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=28802



Post a Comment or Question

Keep it clean and stay on the subject or we may delete your comment.
Your email address is not published. Required fields are marked with an asterisk (*)

*Name   *Email   Notify for updates
Comments
*Enter Code refresh code


 
Sponsor Information
Find and fix SQL Server problems before they happen - SQL diagnostic manager now with predictive analysis!

SQL Backup Pro was the smartest kid at school. Head of the class for compression, encryption and centralized management. Discover why.

Real solutions for real problems. Get in-depth knowledge of all SQL Server features.

Join the over million SQL Server Professionals who get their issues resolved daily.

Free Web Cast - Database development best practices by SQL Server MVPs Grant Fritchey and Jeremy Kadlec


Copyright (c) 2006-2012 Edgewood Solutions, LLC All rights reserved
privacy | disclaimer | copyright | advertise | about
authors | contribute | feedback | giveaways | user groups
Some names and products listed are the registered trademarks of their respective owners.


Edgewood Solutions LLC | MSSharePointTips.com | MSSQLTips.com