Skip to content

Instantly share code, notes, and snippets.

@defilerc
Created January 23, 2019 11:28
Show Gist options
  • Save defilerc/e167bb0760dd17308de57703db314f9f to your computer and use it in GitHub Desktop.
Save defilerc/e167bb0760dd17308de57703db314f9f to your computer and use it in GitHub Desktop.
$smo = 'Microsoft.SqlServer.Management.Smo.'
$wmi = new-object ($smo + 'Wmi.ManagedComputer').
# List the object properties, including the instance names.
$Wmi
# Enable the TCP protocol on the default instance.
$uri = "ManagedComputer[@Name='NT-44']/ ServerInstance[@Name='SQLEXPRESS']/ServerProtocol[@Name='Tcp']"
$Tcp = $wmi.GetSmoObject($uri)
$Tcp.IsEnabled = $true
$Tcp.Alter()
$Tcp
# Enable the named pipes protocol for the default instance.
$uri = "ManagedComputer[@Name='NT-44']/ ServerInstance[@Name='SQLEXPRESS']/ServerProtocol[@Name='Np']"
$Np = $wmi.GetSmoObject($uri)
$Np.IsEnabled = $true
$Np.Alter()
$Np
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment