Bewerken

Delen via


Working with the WMI Provider for Configuration Management

Applies to: SQL Server

This article provides guidance about how to program with the WMI Provider for Computer Management.

Binding

The WMI Provider for Configuration Management is a COM object model and it supports early and late binding. With late binding you can use script languages, such as VBScript, to manipulate the SQL Server services, network settings, and aliases programmatically.

Specifying a Connection String

Applications direct the WMI Provider for Configuration Management to an instance of SQL Server by connecting to a WMI namespace defined by the provider. The Windows WMI service maps this namespace to the provider DLL, and loads the DLL into memory. All instances of SQL Server are represented with a single WMI namespace.

The namespace defaults to the following format. In the format, VV is the major version number of SQL Server. The number is discoverable by running SELECT @@VERSION;.

\\.\root\Microsoft\SqlServer\ComputerManagementVV

When you connect by using PowerShell, the leading \\.\ must be removed. For example, the following PowerShell code lists all WMI classes for a SQL Server 2016, which is major version 13.

Get-WmiObject -Namespace 'root\Microsoft\SqlServer\ComputerManagement13' -List

You can use following PowerShell code to query all available WMI ComputerManagement namespaces.

gwmi -ns 'root\Microsoft\SqlServer' __NAMESPACE | ? {$_.name -match 'ComputerManagement' } | select name

Note: If you are connecting through Windows Firewall you will need to make sure your computers are configured appropriately. See the "Connecting Through Windows Firewall" article in the Windows Management Instrumentation documentation on Microsoft MSDN Web site.

Permissions and Server Authentication

To access the WMI Provider for Configuration Management, the client WMI management script must be running in the context of an administrator on the target computer. You need to be a member of the local Windows administrators group on the computer you want to manage.

The administrator can set group policies to control user access to WMI providers. For more information about setting group policies see "Group Policy and MMC" in the SQL Server Configuration Manager Help.

The WMI management script can be used to update the account under which SQL Server services run.

Security certificates are supported by the WMI Provider for Configuration Management. For more information about certificates, see Encryption Hierarchy.

See Also

SQL Server Configuration Manager