32 CHAPTER 2 Multi-Server Administration
Enrolling SQL Server Instances by Using
Windows PowerShell
Windows PowerShell can also be used to enroll instances. In fact, scripting may be the way
to go if there is a need to enroll a large number of instances into a SQL Server UCP. Let’s say
you need to enroll 200 instances, for example. Using the Enroll Instance Wizard in SSMS can
be very time consuming, because the wizard is a manual process in which you can enroll only
one instance at a time. In contrast, you can enroll 200 instances with a single script by using
Windows PowerShell. The following syntax illustrates how to create a UCP by using Windows
PowerShell. Change the elements in the quotes to match your environment.
$UtilityInstance = new-object -Type Microsoft.SqlServer.Management.Smo.Server
"ComputerName\UCP-Name";
$SqlStoreConnection = new-object –Type
Microsoft.SqlServer.Management.Sdk.Sfc.SqlStoreConnection
$UtilityInstance.ConnectionContext.SqlConnectionObject;
$Utility =
[Microsoft.SqlServer.Management.Utility.Utility]::Connect($SqlStoreConnection);
$Instance = new-object -Type Microsoft.SqlServer.Management.Smo.Server
"ComputerName\ManagedInstanceName";
$InstanceConnection = new-object –Type
Microsoft.SqlServer.Management.Sdk.Sfc.SqlStoreConnection
$Instance.ConnectionContext.SqlConnectionObject;
$ManagedInstance = $Utility.EnrollInstance($InstanceConnection, "ProxyAccount",
"ProxyPassword");
The Managed Instances Dashboard
After you have enrolled all of your instances associated with a UCP, you can review the Man-
aged Instances dashboard, as illustrated in Figure 2-5, to gain quick insight into the health
and utilization of all of your managed instances. The Managed Instances dashboard is cov-
ered in Chapter 5, “Consolidation and Monitoring.”
Comments to this Manuals