Powershell running SMO RRS feed

  • Question

  • I have powershell scripts which I can run through SQLPS and function properly.  I would like to be able to execute them from the powershell engine however I have not been successful adding the commandlets into powershell.  Can someone provide details on this.  For older versions from what I have researched you could do the following: 

    $assemblyInfo = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO")
    if ($assemblyInfo.GetName().Version.Major -ge 10)
    # sql server version is 2008 or later, also load these other assemblies
    [System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.SMOExtended') | Out-Null
    [System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.SQLWMIManagement') | Out-Null


    This however does not appear to work in Sql 2012.


    Any assistance would be appreciated. 

    Wednesday, November 2, 2011 7:06 PM