用于配置 SQL Server Facets 的 Powershell

发布于 2024-12-09 14:35:22 字数 824 浏览 1 评论 0原文

有没有人尝试使用 powershell 配置 SQL Server Facets...我尝试使用下面的代码...并且我能够找到 Facets 的属性,但不知道如何为这些属性设置值。


[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

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

我需要在上面的 Facet 中配置以下值:

  • AdHocRemoteQueriesEnabled = True
  • xp_cmdshell = true

has anyone tried configuring SQL Server Facets using powershell... i tried with below code..and i am able to find out properties of the Facets but not getting idea on how to set values to these properties.


[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

when i execute below command, i see different methods but i am not getting help on how to user those methods.
$Facets | gm

i need to configure below values in the above Facet:

  • AdHocRemoteQueriesEnabled = True
  • xp_cmdshell = true

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

预谋 2024-12-16 14:35:22

虽然它并不完全使用您所展示的内容,但这是我使用的。


[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()

While it's not exactly using what you show but here's what I use.


[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()
梦醒灬来后我 2024-12-16 14:35:22

您可以使用普通批处理和 sp_configure 进行自动化,

我希望这可以帮助有人在自动设置方面时找到答案,这会节省我一些时间。

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

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

sp_configure Transact-SQL 语句:

exec sp_configure "remote access", 1

还:

remote query timeout
remote proc trans

HTH某人

You can automate with normal batch and sp_configure

I hope this helps someone find an answer while automating setting up facets, it would have saved me some time.

Replace AdHocRemoteQueriesEnabled for your answer instead of my working example below "remote access".

Similar to you I was looking for a way to automate, my case was RemoteAccessEnabled instead of installing the manager on any target
machine I wanted to setup as a master. The above special keyword didn't even register in a search.

sp_configure Transact-SQL statement:

exec sp_configure "remote access", 1

also:

remote query timeout
remote proc trans

HTH someone

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文