Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Add servers to server manager powershell

Posted on 2016-08-19
3
Medium Priority
?
430 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 59

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 83

Accepted Solution

by:
David Johnson, CD, MVP earned 2000 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

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

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

The following article is comprised of the pearls we have garnered deploying virtualization solutions since Virtual Server 2005 and subsequent 2008 RTM+ Hyper-V in standalone and clustered environments.
A project that enables an administrator to perform actions within a user session context not just at the time of login but any time later on day(s) or week(s) later.
In this Micro Tutorial viewers will learn how to restore single file or folder from Bare Metal backup image of their system. Tutorial shows how to restore files and folders from system backup. Often it is not needed to restore entire system when onl…
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…

705 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