Skip to content

Instantly share code, notes, and snippets.

@adamfortuno
Created December 14, 2018 21:41
Show Gist options
  • Save adamfortuno/ab7fab10d8de8856af1932d587fcd8dc to your computer and use it in GitHub Desktop.
Save adamfortuno/ab7fab10d8de8856af1932d587fcd8dc to your computer and use it in GitHub Desktop.
SMO Library Load
## Connect to an instance
[void][Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO")
$instance = New-Object 'Microsoft.SqlServer.Management.Smo.Server' -ArgumentList '<instanceName>'
## Connect to an innstance's WMI
[void][Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO")
[void][Reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.SqlWmiManagement")
$instance_wmi = New-Object 'Microsoft.SqlServer.Management.Smo.Wmi.ManagedComputer' -ArgumentList '<instanceName>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment