2011-10-10 72 views
1

有人尝试使用PowerShell配置SQL Server构面...我试着用下面的代码..我能够找出构面的属性,但没有得到如何设置这些值的想法属性。Powershell配置SQL Server构面


[System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.Dmf') | Out-Null 
[System.Reflection.Assembly]::LoadWithPartialNam('Microsoft.SQLServer.Management.Sdk.Sfc') | Out-Null 
$conn = New-Object Microsoft.SQlServer.Management.Sdk.Sfc.SqlStoreConnection("server='Ramu-pc';Trusted_Connection=true") 
$PolicyStore = New-Object Microsoft.SqlServer.Management.DMF.PolicyStore($conn) 
$facets = [Microsoft.SqlServer.Management.Dmf.PolicyStore]::Facets | Where {$_.Name -eq 'ISurfaceAreaFacet'} 
$facets | Format-Table –Auto 

当我执行下面的命令,我看到不同的方法,但我没有得到如何使用这些方法的帮助。 $ Facets |克

我需要在上面刻面配置以下值:

  • AdHocRemoteQueriesEnabled =真
  • 的xp_cmdshell =真

回答

0

虽然它不完全使用你展示什么,但这里是我用什么。


[System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.SMO') | Out-Null 
$server = New-Object 'Microsoft.SqlServer.Management.SMO.Server' ('Ramu-pc') 
$server.Configuration.AdHocDistributedQueriesEnabled.ConfigValue = 1 
$server.Configuration.XPCmdShellEnabled.ConfigValue = 1 
$server.Configuration.Alter() 
0

您可以用正常的批次和sp_configure的

自动化我希望这可以帮助别人找到答案,同时自动设置方面,这将有救了我一些时间。

替换为AdHocRemoteQueriesEnabled为您的答案,而不是我的工作示例下面的“远程访问”。

与您类似我正在寻找一种自动化方式,我的情况是RemoteAccessEnabled,而不是在任何目标上安装管理器 我想设置为主控的机器。上述特殊关键字甚至没有在搜索中注册。

sp_configure的Transact-SQL语句:

exec sp_configure "remote access", 1 

也:

remote query timeout 
remote proc trans 

HTH有人