THE SQL Server Blog Spot on the Web

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

Rob Farley

- Owner/Principal with LobsterPot Solutions (a MS Gold Partner consulting firm), Microsoft Certified Master, Microsoft MVP (SQL Server), APS/PDW trainer and leader of the SQL User Group in Adelaide, Australia. Rob is a former director of PASS, and provides consulting and training courses around the world in SQL Server and BI topics.

PowerShell script to help uninstall SQL Server 2008 R2 Evaluation Edition

Hi! - Great that you've found this page, but it's no longer here! You can find the content over at: http://blogs.lobsterpot.com.au/2011/05/24/powershell-script-to-help-uninstall-sql-server-2008-r2-evaluation-edition/

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

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

 

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
 

Alex said:

The odd characters are unicode. If you save the batch file using notepad, save as, and specify ANSI rather than Unicode, it should work fine

June 22, 2012 10:44 PM
 

Stef Locke said:

I just used this to give my infrastructure guys an uninstall script for all my various bits of sql server lying around.  This has saved me so much time and if they say it doesn't work, then I'll chuck it into notepad and save as ANSI.  I've been looking for something like this for ages.  Great work!

August 31, 2012 10:03 AM
 

llyjak said:

Thanks, you 've saved lot of my time :) Nice job !

October 19, 2012 3:55 PM
 

Ross Gallagher said:

Hi Rob,

I am trying to use your script to help me remove a SQL Server 2008 R2 installation but when I run it I get this message below:

Get-ChildItem : A parameter cannot be found that matches parameter name 'System.Object[]'.

Should I be able to just run your script exactly the way you have written it ?

Thanks.

January 30, 2013 5:01 PM
 

Rob Farley said:

It runs just fine on my machine as is.

Try changing directory one level at a time into HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall to make sure you can. Then slowly add the rest of the script to see what fails.

Could be you don't have enough privilege? You could try making sure you have admin rights escalated in your PowerShell window (ie, Run As Administrator).

January 31, 2013 5:33 AM
 

Ed said:

Brilliant, thanks! Service Pack 1 was not picked up by the script, and I am unable to uninstall it or a hot fix I had installed. Be sure to remove those first before uninstalling sql server.

June 20, 2013 7:18 PM
 

Varun said:

To What THeo was facing with some strange characters. If you save the bat file in ASCII format you wont get that strange character.

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 + '"'; ''} | Out-File .\uninstallR2.bat -Encoding ascii

July 18, 2014 5:16 PM
 

Rockie said:

Hi guy!

You are Great! :) Thank You very much for script, helped a lot.

p.s.: I\d recomment to add "/quiet" on the end of msiexec command - it will avoid confirmations and dialogs

Best regards,

Gennady

February 20, 2016 1:24 PM
 

Rob Farley said:

No worries. Glad it helped.

February 20, 2016 2:30 PM
 

Eric said:

Hello i've the solution :

you need to encode the result file (uninstallR2.bat) in UTF8 without Bom

following a powershell code :

$Path ="D:\DBA\uninstallR2.bat"

$MyFile = Get-Content $Path

$Utf8NoBomEncoding = New-Object System.Text.UTF8Encoding($False)

[System.IO.File]::WriteAllLines($Path, $MyFile, $Utf8NoBomEncoding)

And you can execute :

## Execute command file

$Path ="D:\DBA\uninstallR2.bat"

pushd $Path

.\uninstallR2.bat

popd

Enjoy

April 12, 2016 4:46 AM
 

Rob Farley said:

Yes, Eric. If you make a Unicode file, it won't work. It must be ASCII / UTF8.

April 12, 2016 4:58 AM

Leave a Comment

(required) 
(required) 
Submit

This Blog

Syndication

Tags

No tags have been created or used yet.

News

News? Haven't you read my blog?

My Company


Can't find something?

Contact Me

IM: rob_farley@hotmail.com
Twitter: @rob_farley
Skype: rob_farley
E: rob_farley@hotmail.com

MVP (SQL Server)




Certifications








Adelaide SQL UG

Privacy Statement