Last active
June 5, 2017 12:04
-
-
Save shaneis/19308a7c5fb68b584b6a2a0ee0ec500b to your computer and use it in GitHub Desktop.
Gets the latest SQL Server SMO on the system and creates the Add-Type -AssemblyName parameter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Load the assemblies to work for the latest version of SQL Server on the machine | |
$AddTypeValue = Get-ChildItem -Path C:\Windows\assembly\GAC_MSIL\Microsoft.SqlServer.Smo\ | | |
Sort-Object -Property LastWriteTimeUtc | | |
Select-Object -ExpandProperty Name -First 1; | |
[string]$AssemblyValue = "Microsoft.SqlServer.Smo, Version=$($AddTypeValue.Substring(0, 8)), culture=neutral, PublicKeyToken=$($AddTypeValue.Substring($AddTypeValue.LastIndexOf('__') + 2))"; | |
Add-Type -AssemblyName $AssemblyValue; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The new version here does though!!!!