Sometimes you roll out a database and later decide that the name you picked isn't what you really want. To rename a SQL database and it's associated files, use the Detach and Attach functions. Let's say the original database was named "MyStupidDatabase" and used files C:\MyStupidDatabase.mdf and C:\MyStupidDatabase.ldf. We want to rename the database and it's associated files to "MyFreakingAwesomeDatabase".

Detach Database

To detach the database, use the sp_detach_db stored procedure:

use master
sp_detach_db 'MyStupidDatabase'

After detaching the database, rename MyStupidDatabase.mdf to MyFreakingAwesomeDatabase.mdf and MyStupidDatabase.ldf to MyFreakingAwesomeDatabase.ldf.

Attach Database

Once you've renamed your database and log files, it's time to attach the database with the sp_attach_db stored procedure:

use master
sp_attach_db 'MyFreakingAwesomeDatabase', 'C:\MyFreakingAwesomeDatabase.mdf', 'C:\MyFreakingAwesomeDatabase.ldf'


How do you deploy solutions to your SharePoint farm once you've added them to the solution store? Any of the following will work:

But what if you are standing up a new farm or you've received a boatload of new web parts from your developers?  Deploying multiple solutions using any of the above methods will work, but will be slow, tedious and painful.

The following script will query the farm for all installed web parts that are in a non-deployed status and deploy them all.


deploysolutions.ps1 -URL http://web_application_to_deploy_to


# Title: DeploySolutions
# Version: 1.0, 28DEC11
# Author: James Sanders
# Purpose: Find all installed farm solutions that are not deployed and deploy them

# Command line parameters

If (!$URL) { Write-Host; Write-Host "No URL specified, aborting ..."; Exit;}
Add-PSSnapin Microsoft.SharePoint.PowerShell -EA SilentlyContinue

$Solutions = Get-SPSolution | where {$_.Deployed -eq $FALSE}

ForEach ($Solution in $Solutions) {
  Write-Host "Installing Solution: $($Solution.Name) " -NoNewLine
  Install-SPSolution -Identity $Solution.Name -GACDeployment -CASPolicies -WebApplication $URL
  Do {Write-Host -NoNewline .;Start-Sleep 2;} while ($Solution.Deployed -ne $TRUE)



There are several resources available which show how to configure Alternate Access Mapping (AAM) redirection.  A few good ones are here and here.  The problem I ran into was, once you are done with the redirection, how do you get rid of it?  This required an e-mail to a Microsoft colleague who quickly provided the answer.  As always, the solution is simple once you know what it is :-)

To remove AAM redirection, issue the stsadm addzoneurl command and omit the redirectionurl.  Here's a brief example of setting up and removing AAM redirection:

Adding AAM

stsadm -o addzoneurl -url http://new_url -urlzone default -zonemappedurl http://new_url -redirectionurl http://old_url

Removing AAM

stsadm -o addzoneurl -url http://new_url -urlzone default -zonemappedurl http://new_url


Let's say you build out your portal and later realize that you've fat fingered a web application name.  How do you correct this?!  With SharePoint 2010 and PowerShell, this is all it takes:

$wa=Get-SPWebApplication | where {$_.Name -match "Existing Web App Name"}
$wa.Name="New Web App Name"

Too easy!


Copyright 2011 - 2021 The Lazy SharePoint Admin | All Rights Reserved
menu-circlecross-circle linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram