Solved

Add servers to server manager powershell

Posted on 2016-08-19
3
318 Views
Last Modified: 2016-08-20
Hi Experts,

can someone help understand how i would add multiple servers?  The below article describes how to add a single server to server manager using PS

https://blogs.technet.microsoft.com/keithmayer/2013/08/06/step-by-step-using-powershell-to-add-servers-to-server-manager-in-windows-server-2012/
0
Comment
Question by:cmatchett
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 58

Expert Comment

by:Cliff Galiher
ID: 41763190
Just rerun the command for each server you want to add.  Or write a for-loop (Powershell supports this) and feed it a list of machines...from a text file...hand entered, etc...
0
 
LVL 81

Accepted Solution

by:
David Johnson, CD, MVP earned 500 total points
ID: 41763203
Try this
<#
.Synopsis
Short description
.DESCRIPTION
Add Servers to Server Manager in Windows Server 2012
.EXAMPLE
add-server c:\serverlist.txt
.NOTES
General notes
.FUNCTIONALITY
The functionality that best describes this cmdlet
#>
function Add-ToServerManager
{
[CmdletBinding()]
Param
(
# Servernames to add to Server Manager
[Parameter(Mandatory=$true,
            ValueFromPipeline=$true,
            ValueFromPipelineByPropertyName=$true,
            Position=0)
            ]
[ValidateNotNull()]
[ValidateNotNullOrEmpty()]
[string]$Servername
)
try {
$newserver = @($xml.ServerList.ServerInfo)[0].clone()
$newserver.name = $Servername
$newserver.lastUpdateTime = '0001-01-01T00:00:00'
$newserver.status = '2'
$xml.ServerList.AppendChild($newserver)
$xml.Save($file.FullName)
}
catch {
write-output('Error in Adding server {0} to serverlist xml' -f $Servername)
}
}        

Function Add-Server
{
[CmdletBinding()]
Param
(
# Path to text file that has list of Server Names
[Parameter(Mandatory=$true,
            ValueFromPipeline=$true,
            ValueFromPipelineByPropertyName=$true,
            Position=0)
            ]
[ValidateNotNull()]
[ValidateNotNullOrEmpty()]
[string]$serverlist
)


if (!(test-path $serverlist)){
   write-output ('{0} does not exist' -f $serverlist)
   }
else {
    $servers = get-content -path $serverlist
    get-process ServerManager | stop-process –force
    $file = get-item “$env:USERPROFILE\AppData\Roaming\Microsoft\Windows\ ServerManager\ServerList.xml”
    copy-item –path $file –destination $file-backup –force
    foreach($server in $servers){ add-toservermanager($server)}
    $xml.Save($file.FullName)
    start-process –filepath $env:SystemRoot\System32\ServerManager.exe –WindowStyle Maximized
    }
}

Open in new window

0
 

Author Closing Comment

by:cmatchett
ID: 41763775
pointed in me in right direction
0

Featured Post

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
In previous parts of this Nano Server deployment series, we learned how to create, deploy and configure Nano Server as a Hyper-V host. In this part, we will look for a clustering option. We will create a Hyper-V cluster of 3 Nano Server host nodes w…
This tutorial will walk an individual through the process of configuring basic necessities in order to use the 2010 version of Data Protection Manager. These include storage, agents, and protection jobs. Launch Data Protection Manager from the deskt…
This tutorial will walk an individual through the process of installing the necessary services and then configuring a Windows Server 2012 system as an iSCSI target. To install the necessary roles, go to Server Manager, and select Add Roles and Featu…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question