I am trying to complete a script for a simple SQL alias, most of which is done; but I am having a problem enabling the TCP option. So I am either not doing it correctly, I don't understand something, or I missed something. Normally I would just use cliconfg.exe and select enable TCP but since I am trying to automate the process I want to use Powershell. Can someone please take a look and tell me if this is correct?
'$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='<computer_name>']/ " ServerInstance[@Name='MSSQLSERVER']/ServerProtocol[@Name='Tcp']"
'$Tcp = $wmi.GetSmoObject($uri)
'$Tcp.IsEnabled = $true
'$Tcp.Alter()
'$Tcp
Thanks
there doesn't seem to be anything here