Managing Client Network Protocols with WMI Provider

原创 2012年03月21日 14:58:18

The ClientNetworkProtocol class represents the objects for client network protocols. To see the list of protocols of ClientNetworkProtocol class:

Get-WmiObject -namespace root\Microsoft\SqlServer\ComputerManagement10 -class ClientNetworkProtocol | Select-Object ProtocolName, ProtocolDisplayName,ProtocolOrder

 

To see all the methods you can apply to the client network protocol instances:

Get-WmiObject -namespace root\Microsoft\SqlServer\ComputerManagement10 -class ClientNetworkProtocol | Get-Member -memberType Method | Select-Object Name

 

To disable the Named Pipes protocol:

$clientprotocol=Get-WmiObject –namespace root\Microsoft\SqlServer\ComputerManagement10 -class ClientNetworkProtocol -filter "ProtocolName='np'"
$clientprotocol.SetDisable()

To verify the result:

Get-WmiObject -namespace root\Microsoft\SqlServer\ComputerManagement10 -class ClientNetworkProtocol | Select-Object ProtocolName, ProtocolDisplayName,ProtocolOrder

 

If you’d like to re-enable the Named Pipes protocol and place it above the TCP/IP protocol, which has an order of 2 in the list, you can simply use the SetOrderValue method toset the order of the Named Pipes protocol to 2, to take the place of the TCP/IP protocol:

$clientprotocol=Get-WmiObject –namespace root\Microsoft\SqlServer\ComputerManagement10 -class ClientNetworkProtocol -filter "ProtocolName=’np’"
$clientprotocol.SetOrderValue(2)

To verify the result, sort all the client network protocols by their order:
Get-WmiObject -namespace root\Microsoft\SqlServer\ComputerManagement10 -class ClientNetworkProtocol | Select-Object ProtocolName, ProtocolDisplayName,ProtocolOrder | Sort-Object ProtocolOrder

 

To get the property names and their associated protocol names of ClientNetworkProtocolProperty:

Get-WmiObject -namespace root\Microsoft\SqlServer\ComputerManagement10 -class ClientNetworkProtocolProperty | Select-Object PropertyName, ProtocolName

 

To change the default port of the TCP/IP protocol from 1433 to 7001:

$strComputer = "."
$protocolproperty=Get-WmiObject –computerName $strComputer –namespace root\Microsoft\SqlServer\ComputerManagement10 –class ClientNetworkProtocolProperty -filter "PropertyName=’Default Port’"
$protocolproperty.SetNumericalValue(7001)

To verify the result:

Get-WmiObject -namespace root\Microsoft\SqlServer\ComputerManagement10 -class ClientNetworkProtocolProperty -filter "PropertyName=’Default Port’"

 

 The complete script(ChangeTCPIPDefaultPort.ps1):

$wmi=Get-WmiObject -namespace root\Microsoft\SqlServer\ComputerManagement10 -class ServerNetworkProtocolProperty `
-filter "PropertyName='TcpPort' and IPAddressName='IPAll' and InstanceName='MSSQLSERVER'?

$wmi.SetStringValue(7001) | Out-Null

$sqlservice = Get-WmiObject -namespace root\Microsoft\SqlServer\ComputerManagement10 -class SqlService `
-filter "ServiceName='MSSQLSERVER'"

$sqlservice.StopService() | Out-Null

$sqlservice.StartService() | Out-Null

# Confirm the default port number has been changed
Get-WmiObject -namespace root\Microsoft\SqlServer\ComputerManagement10 -class ServerNetworkProtocolProperty `
-filter "PropertyName='TcpPort' and IPAddressName='IPAll' and InstanceName='MSSQLSERVER'" | Select-Object PropertyStrVal

 

相关文章推荐

Managing SQL Server Client Aliases with WMI Provider

SQL Server client aliases make user connections easier, faster, and more convenient. Each alias save...

The provider is not compatible with the version of Oracle client sometimes (提供程序与此版本的 Oracle 客户机不兼容)

其实这个问题很直观,就是你在C#项目中使用的Oracal.DataAcess.dll文件的版本与你电脑上安装的ODAC.EXE(ODP.NET)版本不一致,不论是32位或者是64位平台不一致,还是版本...

协议的使用(Working with Protocols)

在现实世界中,在处理某些情况时,人们往往需要遵守严格的程序。例如,执法官员在进行查询或收集证据时,要求“遵守协议”。 在面向对象编程的世界中,在给定的情况下,能够定义一组对象的行为是非常重要的。例如,...

How to configure XDB for using ftp and http protocols with ASM [ID 357714.1]

Configuration of XDB(XML Database) to be able to use ftp and http protocols to browse and manage ASM...

Managing Projects with GNU make 学习笔记

1. 简介 makefile定义了一种语言来描述源代码、中间文件及可执行文件之间的关系。 如果命令行指定了目标,则更新指定的目标,如果没有,则取第一个目标,也即默认目标。 1.1 目标与依赖...
  • yarsen
  • yarsen
  • 2012年03月31日 14:31
  • 1270

Miscellanies of iOS 3) Managing Memory with ARC

pp101  Not just copy and paste anymore...              For the usage of review 1. All Objective-C ...

使用Eclipse和ADT插件管理Android项目(Managing Project from Eclipse with ADT)

简介 使用Eclipse和ADT插件可以提供可视化界面和向导来创建三种类型的项目(Android项目,库项目,以及测试项目): *一个Android项目包含了将项目打包成.apk安装文件所需要的所有...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:Managing Client Network Protocols with WMI Provider
举报原因:
原因补充:

(最多只允许输入30个字)