Load the latest .NET assembly installed in your system, e.g. for SQL SMO

Load the latest .NET assembly for that PowerShell version using the following command:

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo")

 

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO") | out-null
 $SMOserver = New-Object ('Microsoft.SqlServer.Management.Smo.Server') -argumentlist $SrcServer
 $WhichVersion = $SMOserver.Version.Major

This command will grab the latest SMO installed in your system. You can also use this method with PowerShell 2.0 and later. More here.

Comments are closed.

Post Navigation