title: Problem accessing SQL Server from PowerShell
body: <p>I'm trying to implement a backup management script i found at <a href="http://sev17.com/2011/03/restore-and-relocate-database-files-using-powershell/" rel="nofollow">http://sev17.com/2011/03/restore-and-relocate-database-files-using-powershell/</a></p>
  
  <p>The article says it depends on SQLPSX version 2.3.2.1 or higher - I have the most current version.</p>
  
  <p>attempting to execute this line:</p>
  
  <pre><code>$server = get-sqlserver $sqlserver
  </code></pre>
  
  <p>results in:</p>
  
  <pre><code>New-Object : Cannot find type [Microsoft.SqlServer.Management.Common.ServerConnection]: make sure the assembly containing this type is loaded.
  At C:\Users\...\Documents\WindowsPowerShell\Modules\sqlserver\SQLServer.psm1:68 char:24
  +     { $con = new-object &lt;&lt;&lt;&lt;  ("Microsoft.SqlServer.Management.Common.ServerConnection") $sqlserver }
  </code></pre>
  
  <p>result of get-module -listAvailable</p>
  
  <pre><code>    ModuleType Name                      ExportedCommands                                                           
      ---------- ----                      ----------------                                                           
      Script     adoLib                    {}                                                                         
      Manifest   Agent                     {Get-AgentTargetServerGroup, Get-AgentProxyAccount, Get-AgentJobSchedule...
      Script     ISECreamBasic             {}                                                                         
      Script     mySQLLib                  {}                                                                         
      Script     OracleClient              {}                                                                         
      Script     OracleIse                 {}                                                                         
      Script     PBM                       {}                                                                         
      Script     PerfCounters              {}                                                                         
      Manifest   Pscx                      {}                                                                         
      Manifest   Repl                      {Get-ReplEnumSubscriptions2, Get-ReplPublisherMonitor, Get-ReplEnumPubli...
      Manifest   ShowMbrs                  {Get-ShowMbrs, Set-ShowMbrs, New-ShowMbrs, Get-GroupUser}                  
      Script     SQLIse                    {}                                                                         
      Manifest   SQLMaint                  {Get-SqlIndexFragmentation, New-UserMember, Invoke-SqlIndexRebuild, Get-...
      Manifest   SQLParser                 {Test-SqlScript, Out-SqlScript}                                            
      Script     SQLProfiler               {}                                                                         
      Script     SQLPSX                    {}                                                                         
      Manifest   sqlserver                 {Get-SqlScripter, Get-SqlIndexFragmentation, Remove-SqlServerRoleMember,...
      Manifest   SSIS                      {New-ISItem, Get-ISPackage, Get-ISItem, Copy-ISItemFileToSQL...}           
      Manifest   WPK                       {}                                                                         
      Manifest   AppLocker                 {}                                                                         
      Manifest   BitsTransfer              {}                                                                         
      Manifest   PSDiagnostics             {}                                                                         
      Manifest   TroubleshootingPack       {}                                                                         
      Manifest   WebAdministration         {}    
  </code></pre>
  
  <p>RE: SMO</p>
  
  <pre><code>[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.ConnectionInfo") 
  [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO")
  [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SmoExtended") 
  </code></pre>
  
  <p>results:</p>
  
  <pre><code>True   v2.0.50727     C:\Windows\assembly\GAC_MSIL\Microsoft.SqlServer.ConnectionInfo\10.0.0.0__89845dcd8080cc91\Microsoft.SqlServer.ConnectionInfo.dll                             
  True   v2.0.50727     C:\Windows\assembly\GAC_MSIL\Microsoft.SqlServer.Smo\10.0.0.0__89845dcd8080cc91\Microsoft.SqlServer.Smo.dll                                                   
  True   v2.0.50727     C:\Windows\assembly\GAC_MSIL\Microsoft.SqlServer.SmoExtended\10.0.0.0__89845dcd8080cc91\Microsoft.SqlServer.SmoExtended.dll                                   
  New-Object : Cannot find type [Microsoft.SqlServer.Management.Common.ServerConnection]: make sure the assembly containing this type is loaded.
  </code></pre>