用于配置 SQL Server Facets 的 Powershell
有没有人尝试使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
虽然它并不完全使用您所展示的内容,但这是我使用的。
While it's not exactly using what you show but here's what I use.
您可以使用普通批处理和 sp_configure 进行自动化,
我希望这可以帮助有人在自动设置方面时找到答案,这会节省我一些时间。
将
AdHocRemoteQueriesEnabled
替换为您的答案,而不是我下面的“远程访问”工作示例。与您类似,我一直在寻找一种自动化方法,我的案例是 RemoteAccessEnabled,而不是在任何目标上安装管理器
我想设置为主机的机器。上述特殊关键字甚至没有在搜索中注册。
sp_configure Transact-SQL 语句:
还:
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:
also:
HTH someone