Solved

Add servers to server manager powershell

Posted on 2016-08-19
3
262 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 80

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

Free Webinar: AWS Backup & DR

Join our upcoming webinar with experts from AWS, CloudBerry Lab, and the Town of Edgartown IT to discuss best practices for simplifying online backup management and cutting costs.

Question has a verified solution.

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

The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. Based on the inputs you provide, it generates images for deployment and creates reusable PowerShell scripts that …
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…
In this Micro Tutorial viewers will learn how to use Windows Server Backup to create full image of their system. Tutorial shows how to install Windows Server Backup Feature on Windows 2012R2 and how to configure scheduled Bare Metal Recovery backup.…
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…

733 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