THE SQL Server Blog Spot on the Web

Welcome to SQLblog.com - The SQL Server blog spot on the web Sign in | Join | Help
in Search

Rob Farley

- Owner/Principal with LobsterPot Solutions (a MS Gold Partner consulting firm), Microsoft MVP (SQL Server) and leader of the SQL User Group in Adelaide, Australia. Rob is also a Director of PASS, and runs training courses around the world in SQL Server and BI topics.

PowerShell script to help uninstall SQL Server 2008 R2 Evaluation Edition

If you haven’t been caught by a client (or even yourself) installing SQL 2008 R2 Evaluation Edition and then letting it expire, you might not realise the pain that this causes. To say it’s frustrating is a serious understatement.

Fellow SQL MVP and SQLBlog blogger Aaron Bertrand (@aaronbertrand) has an excellent post on the matter, which he put together back in October 2010. I had cause to use it recently, but got somewhat put off by searching through the registry.

So I put a line of PowerShell together (which I’ve split across 5 for easier reading):

Get-ChildItem HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall |
select @{Name='Guid';Expression={$_.PSChildName}}, @{Name='Disp';Expression={($_.GetValue("DisplayName"))}} |
where-object {$_.Disp -ilike "*SQL*R2*"} |
where-object {$_.Guid -like '{*'} |
% {"rem " + $_.Disp; 'msiexec /x "' + $_.Guid + '"'; ''} > uninstallR2.bat

If you run this, it will produce the file that Aaron recommended. You can look down it for anything you don’t want to get rid of, and maybe reorder the odd thing, and then run it. Then you should be able to install Developer Edition, and breathe much easier.

The script is quite straight forward, it just lists everything in the uninstall bit of the registry, gets the DisplayName values out, filters them, and outputs the results in a few lines for the batch file. Nothing amazingly complicated, but useful for getting through the list quickly.

(Big thanks to Aaron for working out what was required for the uninstall, and Aaron Nelson (@sqlvariant) for answering a quick question when I was putting the final touches on the script)

Published Tuesday, May 24, 2011 2:04 AM by Rob Farley
Filed under: ,

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

 

Something for the Weekend – SQL Server Links 27/05/11 | John Sansom - SQL Server DBA in the UK said:

May 27, 2011 6:48 AM
 

Frank Q said:

What I have to change in this script to uninstall SQL Server 2008 evaluation after I have installed SQL Server 2008 R2?

May 29, 2011 7:19 AM
 

Rob Farley said:

Hi Frank,

Tweak the bit that says *SQL*R2*. You could even just put * and then go through the resultant batch file to look for the things you want to keep. But maybe keep the *SQL* bit and then look for the stuff you want to get rid of.

Rob

May 29, 2011 7:52 AM
 

THeo said:

I created the uninstallR2.bat file using the PowerShell script provided above.

Unfortunately the bat file does not run.

I get a message telling me that

"_R" is not recognized as an internal or external command, operable program or batch file"

Note the under score is actually a square symbol.

I am wondering if the bat file name or location is my issue?

I looked at the services running and found MsDtsServer100 running so I stopped it. Maybe there are other SqlServer services to stop?

I also ran the bat file as administrator.

Any assistance will be appreciated.

March 25, 2012 11:34 AM
 

Rob Farley said:

Hi Theo - what's in your .bat file? Does it contain any strange characters?

March 25, 2012 5:56 PM
 

Theo said:

Hi Rob, to the eye nothing noticeable.

As an experiment I REM all the msiexec and the error still occurs.

I created a bat file with a couple of REM lines and it worked ok.

The UninstallR2.bat result I got running your powershell script gave me 23 msiexec lines comparing to Aaron Bertrand's seems excessive?

March 25, 2012 9:33 PM
 

Theo said:

Given that I have never used Powershell scripting before I became suspicious that maybe the file did not get created with the correct properties.

So I copied the contents into another file I created using note pad and it is now running.

Not sure what the issue was, maybe Powershell needs configuring?

March 25, 2012 9:52 PM
 

Rob Farley said:

(just started typing again)

Yes - I suppose it's possible that somewhere along the way there's a strange character getting inserted instead of a space. I'm pleased you've got it working.

March 25, 2012 9:56 PM
 

Theo said:

Thanks for your help.

The bat file generated 23 uninstall commands, working through the registry would have been a time consuming trial and error exercise.

I ran the bat file 3 times, on the 3rd run it didn't find anything to uninstall.

However, under Start-All Programs I still see some Sql Server 2008 menu options.

I can still run the Installation Center, documentation and tutorials and Visual Studio.

I will try to install the developer edition tonight and see if that works.

March 26, 2012 5:26 AM
 

Rob Farley said:

You might see some SQL 2008 entries still, because you were only looking for R2 stuff. If you tweak the script a little, you can probably find the list of SQL 2008 things too.

March 26, 2012 5:48 AM
 

Theo said:

Thanks the only item I couldn't remove was the Sql Server 2008 R2 documentation.

I will try to install the developer edition now and see if all goes well.

March 27, 2012 10:26 AM

Leave a Comment

(required) 
(optional)
(required) 
Submit
Powered by Community Server (Commercial Edition), by Telligent Systems
  Privacy Statement