Share via


Use PowerShell to Customize Server Manager

Summary : Guest blogger, Rolf Masuch, talks about using Windows PowerShell to customize Server Manager.
Microsoft Scripting Guy, Ed Wilson, is here. Today we have a guest post written by Rolf Masuch, who is a senior consultant for Microsoft in Germany. Today is Rolf’s birthday, and he wanted to start the celebration off right by sharing a couple of cool scripts with us. Take it away Rolf…
When it comes to the new versions of Windows Server 2012 R2 and Windows Server 2012, one of my most-loved changes is to Server Manager. The new Server Manager Dashboard looks like this:

Lots of documents have been written already about this new way of working. Today I’d like to share two extension scripts that I thought would be helpful for the community because when it comes to automating Server Manager, you cannot do two things:

Add servers to your list of managed servers
Create groups that contain a custom list of servers

You will find the respective menu entries in Server Manager when you click Manage .

But first, let’s look behind the curtain of Server Manager. It stores information in an XML file that is saved per user at this location:
$ENV:APPDATA\Microsoft\Windows\ServerManager\ServerList.xml
Additionally, it is useful to know that every time you close a running Server Manager instance, it can overwrite your scripted changes. We want to take care that before we make changes to the XML file, we close the Server Manager process. We also need to make all changes in an elevated process.
When it comes down to writing additional entries to the file, you may think, “Hey, it is just XML, this is easy.” But when you look at the structure of the XML file, you see that this is not so simple. The following example is from a freshly installed system with one additional group:
ServerManager.xml
***
<?xml version="1.0" encoding="utf-8"?>
<ServerList xmlns:xsd=" https://www.w3.org/2001/XMLSchema " xmlns:xsi=" https://www.w3.org/2001/XMLSchema-instance " localhostName="MyCloudComp001" xmlns="urn:serverpool-schema">
<ServerInfo name="MyCloudComp001" status="1" lastUpdateTime="2013-08-08T09:01:26.7659233+00:00" locale="en-US" /><ServerGroupInfo id="3" name="MyGroup" />
<ServerGroupMembership server="MyCloudComp001" serverGroupId="3" />
</ServerList>
***
As you see from the initial lines, the XML structure is using an additional namespace that is...(read more)