2011-06-13 1 views
1

SQL Server를 수정해야하는 새 제품을 설치하려고합니다.명명 된 파이프 및 tcp ip를 터닝 자동화

특히, tcp/ip를 활성화하고 명명 된 파이프를 켭니다. 나는 그것을 수동으로하는 방법을 안다. 내가 원하는 것은 SQL 또는 C# 코드를 사용하여 새로운 고객을 위해이를 자동화하는 방법입니다.

나는 올바른 방향에 대한 제안을 원합니다.

답변

1

C# 및 SMO (Server Management Objects)를 사용하여 수행 할 수 있습니다. 필요한 클래스는 Microsoft.SqlServer.Smo 및 Microsoft.SqlServer.WmiManagement 라이브러리에 있습니다.

다음은 동일한 개체를 사용하는 Powershell 스 니펫입니다. 잘하면, 그것은 올바른 길을 가리킬 것입니다.

$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 

# Enable the named pipes protocol for the default instance. 
$uri = "ManagedComputer[@Name='<computer_name>']/ ServerInstance[@Name='MSSQLSERVER']/ServerProtocol[@Name='Np']" 
$Np = $wmi.GetSmoObject($uri) 
$Np.IsEnabled = $true 
$Np.Alter() 
$Np