GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Skip to Ask Learn chat experience
  • Download Microsoft Edge

This view

  • Original page
  • New address

GeezerVison is showing learn.microsoft.com — How to enable the TCP protocol using SQLPS - SQL Server PowerShell

Read in English Edit

Note

Access to this page requires authorization. You can try signing in or changing directories.

Access to this page requires authorization. You can try changing directories.

Enable the TCP protocol

Note

There are two SQL Server PowerShell modules; SqlServer and SQLPS.

The SqlServer module is the current PowerShell module to use.

The SQLPS module is included with the SQL Server installation (for backward compatibility) but is no longer updated.

The SqlServer module contains updated versions of the cmdlets in SQLPS and includes new cmdlets to support the latest SQL features.

Install the SqlServer module from the PowerShell Gallery.

For more information, visit SQL Server PowerShell.

To enable the TCP protocol when connected to the console with SQLPS.

  1. Open a command prompt and type:

    C:\> SQLPS.EXE
    

    Tip

    If SQLPS is not found, you might need to open a new command prompt or just log off and log back on.

  2. At the PowerShell command prompt, type:

    # Instantiate a ManagedComputer object that exposes primitives to control the
    # Installation of SQL Server on this machine.
    
    $wmi = New-Object 'Microsoft.SqlServer.Management.Smo.Wmi.ManagedComputer' localhost
    
    # Enable the TCP protocol on the default instance. If the instance is named,
    # replace MSSQLSERVER with the instance name in the following line.
    
    $tcp = $wmi.ServerInstances['MSSQLSERVER'].ServerProtocols['Tcp']
    $tcp.IsEnabled = $true
    $tcp.Alter()
    
    # You need to restart SQL Server for the change to persist
    # -Force takes care of any dependent services, like SQL Agent.
    # Note: If the instance is named, replace MSSQLSERVER with MSSQL$ followed by
    # the name of the instance (e.g., MSSQL$MYINSTANCE)
    
    Restart-Service -Name MSSQLSERVER -Force
    

Enable the TCP protocol when connected to the console but not using SQLPS

  1. Open a command prompt and type:

    C:\> PowerShell.exe
    
  2. At the PowerShell command prompt, type:

    # Get access to SqlWmiManagement DLL on the machine with SQL
    # we are on, which is where SQL Server was installed.
    # Note: This is installed in the GAC by SQL Server Setup.
    
    [System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.SqlWmiManagement')
    
    # Instantiate a ManagedComputer object that exposes primitives to control the
    # Installation of SQL Server on this machine.
    
    $wmi = New-Object 'Microsoft.SqlServer.Management.Smo.Wmi.ManagedComputer' localhost
    
    # Enable the TCP protocol on the default instance. If the instance is named,
    # replace MSSQLSERVER with the instance name in the following line.
    
    $tcp = $wmi.ServerInstances['MSSQLSERVER'].ServerProtocols['Tcp']
    $tcp.IsEnabled = $true
    $tcp.Alter()
    
    # You need to restart SQL Server for the change to persist
    # -Force takes care of any dependent services, like SQL Agent.
    # Note: If the instance is named, replace MSSQLSERVER with MSSQL$ followed by
    # the name of the instance (e.g., MSSQL$MYINSTANCE)
    
    Restart-Service -Name MSSQLSERVER -Force
    

Related content

  • Install the SQL Server PowerShell module
  • SQL Server PowerShell

Feedback

Was this page helpful?

No

Additional resources


  • Last updated on 2024-07-03
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.