The SQL MO loader script generates the following error if you run it more than once (as you might during debugging):
Update-FormatData : There were errors in loading the format data file:
Microsoft.PowerShell, C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\SQLProvider.Format.ps1xml : File skipped because it was already present from "Microsoft.PowerShell".
Microsoft.PowerShell, C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\SQLProvider.Format.ps1xml : File skipped because it was already present from "Microsoft.PowerShell".
To fix this, replace
Push-Location
cd $SqlPsPath
Update-FormatData -PrependPath SQLProvider.Format.ps1xml
Pop-Location
..with:
$SqlFormat = Get-FormatData 'Microsoft.SqlServer.Management.*'
if(0 -eq $SqlFormat.Length)
{
Push-Location
cd $SqlPsPath
Update-FormatData -PrependPath SQLProvider.Format.ps1xml
Pop-Location
}