{"id":3025,"date":"2016-01-22T11:16:26","date_gmt":"2016-01-22T14:16:26","guid":{"rendered":"http:\/\/www.radians.com.ar\/blog\/?p=3025"},"modified":"2018-01-16T16:53:23","modified_gmt":"2018-01-16T19:53:23","slug":"windows-server-2012-r2-como-customizar-el-server-manager-con-powershell-howto","status":"publish","type":"post","link":"https:\/\/www.radians.com.ar\/blog\/?p=3025","title":{"rendered":"Windows Server 2012 R2, como customizar el Server Manager con PowerShell {HowTo}"},"content":{"rendered":"<p align=\"justify\">Ya hemos visto como funciona el Server Manager, y hemos grabado varios videos en cuanto a su funcionalidad: <a href=\"http:\/\/www.radians.com.ar\/blog\/?p=2849\">Administrando nuestros Servers 2008 con Windows Server 2012 Server Manager {ScreenCast}<\/a>. Hoy veremos como podemos modificarlo con la ayuda de PowerShell. Usualmente el Dashboard del Server Manager se ve as\u00ed:<\/p>\n<p><a href=\"http:\/\/www.radians.com.ar\/Articulos\/Images2014\/WindowsServer2012R2comocustomizarelServe_EE52\/01.png\"><img loading=\"lazy\" decoding=\"async\" title=\"www.radians.com.ar\" style=\"border-top: 0px; border-right: 0px; border-bottom: 0px; border-left: 0px; display: inline\" border=\"0\" alt=\"www.radians.com.ar\" src=\"http:\/\/www.radians.com.ar\/Articulos\/Images2014\/WindowsServer2012R2comocustomizarelServe_EE52\/01_thumb.png\" width=\"544\" height=\"375\" \/><\/a> <\/p>\n<p align=\"justify\">Hoy me gustar\u00eda compartir con ustedes dos scripts que fueron publicados hace un tiempo, porque cuando se trata de la automatizaci\u00f3n del Administrador de servidores, no se puede hacer dos cosas:<\/p>\n<ul>\n<li>\n<div align=\"justify\">A\u00f1adir servidores a la lista de servidores gestionados<\/div>\n<\/li>\n<li>\n<div align=\"justify\">Crear grupos que contienen una lista personalizada de servidores<\/div>\n<\/li>\n<\/ul>\n<p align=\"justify\">Si vemos las opciones que se despliegan cuando hacemos un clic en <em><strong>Manage<\/strong><\/em> veremos las siguientes opciones:<\/p>\n<p><a href=\"http:\/\/www.radians.com.ar\/Articulos\/Images2014\/WindowsServer2012R2comocustomizarelServe_EE52\/02.png\"><img loading=\"lazy\" decoding=\"async\" title=\"www.radians.com.ar\" style=\"border-top: 0px; border-right: 0px; border-bottom: 0px; border-left: 0px; display: inline\" border=\"0\" alt=\"www.radians.com.ar\" src=\"http:\/\/www.radians.com.ar\/Articulos\/Images2014\/WindowsServer2012R2comocustomizarelServe_EE52\/02_thumb.png\" width=\"444\" height=\"308\" \/><\/a> <\/p>\n<p>Pero en primer lugar, echemos un vistazo detr\u00e1s del Administrador de servidores. Esta consola almacena la informaci\u00f3n en un archivo XML que se guarda por usuario en este lugar:<\/p>\n<p align=\"center\"><font color=\"#ff8000\" face=\"OCR A Extended\">$ENV:APPDATA\\Microsoft\\Windows\\ServerManager\\ServerList.xml <\/font><\/p>\n<p align=\"justify\">Adem\u00e1s, es \u00fatil saber que cada vez que se cierra una instancia en ejecuci\u00f3n del Administrador de servidores, podemos sobrescribir los cambios de secuencias de comandos. Queremos tener cuidado de que antes de hacer cambios en el archivo XML, cerramos el proceso Administrador de servidores. Tambi\u00e9n tenemos que hacer todos los cambios con elevaci\u00f3n de permisos.<\/p>\n<p align=\"justify\">Por mas que sea un simple archivo XML, no hay que simplificarlo, ya que si nos equivocamos la consola dejara de funcionar. Si vemos en detalle la estructura del archivo XML, se ve que esto no es tan simple. El siguiente ejemplo es de un sistema reci\u00e9n instalado con un grupo adicional:<\/p>\n<p><font color=\"#ff8000\" face=\"OCR A Extended\">ServerManager.xml     <br \/>***      <br \/>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;      <br \/>&lt;ServerList xmlns:xsd=&quot;<\/font><a href=\"http:\/\/www.w3.org\/2001\/XMLSchema\"><font color=\"#ff8000\" face=\"OCR A Extended\">http:\/\/www.w3.org\/2001\/XMLSchema<\/font><\/a><font color=\"#ff8000\" face=\"OCR A Extended\">&quot; xmlns:xsi=&quot;<\/font><a href=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"><font color=\"#ff8000\" face=\"OCR A Extended\">http:\/\/www.w3.org\/2001\/XMLSchema-instance<\/font><\/a><font color=\"#ff8000\" face=\"OCR A Extended\">&quot; localhostName=&quot;MyCloudComp001&quot; xmlns=&quot;urn:serverpool-schema&quot;&gt;     <br \/>&lt;ServerInfo name=&quot;MyCloudComp001&quot; status=&quot;1&quot; lastUpdateTime=&quot;2013-08-08T09:01:26.7659233+00:00&quot; locale=&quot;en-US&quot; \/&gt;&lt;ServerGroupInfo id=&quot;3&quot; name=&quot;MyGroup&quot; \/&gt;      <br \/>&lt;ServerGroupMembership server=&quot;MyCloudComp001&quot; serverGroupId=&quot;3&quot; \/&gt;      <br \/>&lt;\/ServerList&gt;      <br \/>***<\/font><\/p>\n<p align=\"justify\">Como se puede ver desde las l\u00edneas iniciales, la estructura XML se utiliza un espacio de nombres adicional que se denomina: <strong><font color=\"#ff8000\" face=\"OCR A Extended\">urn:serverpool-schema<\/font><\/strong><strong>.<\/strong> Cuando se desea agregar nuevos elementos a esta estructura, hay que hacerlo de forma manual. Para hacerlo podemos utilizar la secuencia de comandos del script <font color=\"#ff8000\" face=\"OCR A Extended\">Add-ServerToManagedServerList.ps1<\/font>. Aqu\u00ed est\u00e1n las l\u00edneas mas importantes:<\/p>\n<p><font color=\"#ff8040\" face=\"OCR A Extended\">$NewServer = $ServerList.CreateElement(&quot;ServerInfo&quot;)     <br \/>$NewServer.SetAttribute(&quot;name&quot;,$ComputerName.ToString()) | Out-Null      <br \/>$NewServer.SetAttribute(&quot;xmlns&quot;,&quot;urn:serverpool-schema&quot;) | Out-Null      <br \/>$ServerList.ServerList.AppendChild($NewServer) | Out-Null<\/font><\/p>\n<p>As\u00ed estableciendo el atributo justo en la notaci\u00f3n de la derecha hace el truco para nosotros. Ahora tenemos el servidor que acaba de agregar en el Administrador de servidores.<\/p>\n<p><a href=\"http:\/\/www.radians.com.ar\/Articulos\/Images2014\/WindowsServer2012R2comocustomizarelServe_EE52\/03.png\"><img loading=\"lazy\" decoding=\"async\" title=\"www.radians.com.ar\" style=\"border-top: 0px; border-right: 0px; border-bottom: 0px; border-left: 0px; display: inline\" border=\"0\" alt=\"www.radians.com.ar\" src=\"http:\/\/www.radians.com.ar\/Articulos\/Images2014\/WindowsServer2012R2comocustomizarelServe_EE52\/03_thumb.png\" width=\"544\" height=\"414\" \/><\/a> <\/p>\n<p>Lo mismo ocurre cuando se trata de agregar el servidor a un grupo existente.<\/p>\n<p><font color=\"#ff8040\" face=\"OCR A Extended\">$NewServerInGroup = $ServerList.CreateElement(&quot;ServerGroupMembership&quot;)     <br \/>$NewServerInGroup.SetAttribute(&quot;server&quot;,$ComputerName.ToString()) | Out-Null      <br \/>$NewServerInGroup.SetAttribute(&quot;serverGroupId&quot;,$PSItem.Id) | Out-Null      <br \/>$NewServerInGroup.SetAttribute(&quot;xmlns&quot;,&quot;urn:serverpool-schema&quot;) | Out-Null      <br \/>$ServerList.ServerList.AppendChild($NewServerInGroup) | Out-Null<\/font><\/p>\n<p align=\"justify\">Debido a que este es un grupo existente, tenemos que asegurarnos de que el ID del grupo se agrega a los atributos de la entrada. As\u00ed que esta es la forma de agregar un nuevo servidor a la lista de servidores administrados. Sencillo, \u00bfno?&#160; Un nuevo grupo de servidores se muestra aqu\u00ed:<\/p>\n<p><a href=\"http:\/\/www.radians.com.ar\/Articulos\/Images2014\/WindowsServer2012R2comocustomizarelServe_EE52\/04.png\"><img loading=\"lazy\" decoding=\"async\" title=\"www.radians.com.ar\" style=\"border-top: 0px; border-right: 0px; border-bottom: 0px; border-left: 0px; display: inline\" border=\"0\" alt=\"www.radians.com.ar\" src=\"http:\/\/www.radians.com.ar\/Articulos\/Images2014\/WindowsServer2012R2comocustomizarelServe_EE52\/04_thumb.png\" width=\"544\" height=\"416\" \/><\/a> <\/p>\n<p>Tambi\u00e9n puede a\u00f1adir algunos grupos personalizados con el script <font color=\"#ff8040\" face=\"OCR A Extended\">New-ServerManagerGroup.ps1<\/font>. Se crea un n\u00famero aleatorio y lo utiliza como el ID de grupo necesario.<\/p>\n<p><font color=\"#ff8040\" face=\"OCR A Extended\">$Global:ServerGroupID = Get-Random -Maximum 1000     <br \/>$NewServerGroup = $ServerList.CreateElement(&quot;ServerGroupInfo&quot;)      <br \/>$NewServerGroup.SetAttribute(&quot;id&quot;,$Global:ServerGroupID) | Out-Null      <br \/>$NewServerGroup.SetAttribute(&quot;name&quot;,$Name) | Out-Null      <br \/>$NewServerGroup.SetAttribute(&quot;xmlns&quot;,&quot;urn:serverpool-schema&quot;) | Out-Null      <br \/>$ServerList.ServerList.AppendChild($NewServerGroup) | Out-Null<\/font><\/p>\n<p align=\"justify\">Aqu\u00ed podemos ver interruptores adicionales, como <strong>-Backup <\/strong>(para guardar el <font color=\"#ff8040\" face=\"OCR A Extended\">ServerManager.xml<\/font> anterior) y <strong>&#8211;<font color=\"#ff8040\" face=\"OCR A Extended\">StartServerManager<\/font><\/strong> (para el lanzamiento del Administrador de servidores despu\u00e9s de sus adiciones). Tengamos en cuenta que los scripts proporcionados comprobemos siempre que no este un proceso <font color=\"#ff8040\" face=\"OCR A Extended\">servermanager.exe<\/font> y en caso de ser necesario finalizarlo.<\/p>\n<p align=\"justify\">Los siguientes scripts se cargan en el Script Center Repository: <\/p>\n<ul>\n<li><a href=\"http:\/\/gallery.technet.microsoft.com\/scriptcenter\/New-ServerManagerGroupps1-50053d60\">New-ServerManagerGroup.ps1<\/a><\/li>\n<li><a href=\"http:\/\/gallery.technet.microsoft.com\/scriptcenter\/Add-ServerToManagedServerLi-8c722657\">Add-ServerToManagedServerList.ps1<\/a><\/li>\n<\/ul>\n<p>Espero les sea de interes y utilidad. Saludos. Roberto Di Lello.<\/p>\n<h4>Mas informaci\u00f3n: <\/h4>\n<li><a href=\"http:\/\/gallery.technet.microsoft.com\/scriptcenter\/New-ServerManagerGroupps1-50053d60\">Script Center Repository &#8211; New-ServerManagerGroup.ps1<\/a> <\/li>\n<li><a href=\"http:\/\/gallery.technet.microsoft.com\/scriptcenter\/Add-ServerToManagedServerLi-8c722657\">Script Center Repository &#8211; Add-ServerToManagedServerList.ps1<\/a><\/li>\n<li><a title=\"http:\/\/blogs.technet.com\/b\/heyscriptingguy\/archive\/2013\/08\/16\/weekend-scripter-use-powershell-to-customize-server-manager.aspx\" href=\"http:\/\/blogs.technet.com\/b\/heyscriptingguy\/archive\/2013\/08\/16\/weekend-scripter-use-powershell-to-customize-server-manager.aspx\">Hey, Scripting Guy! Blog<\/a><\/li>\n","protected":false},"excerpt":{"rendered":"<p>Ya hemos visto como funciona el Server Manager, y hemos grabado varios videos en cuanto&#8230;<\/p>\n","protected":false},"author":1,"featured_media":4291,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[158,281],"tags":[192,215,243,290],"class_list":["post-3025","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-windows-server-2012","category-281","tag-script","tag-sbs-howto","tag-windows-server-2012-r2","tag-windows-server-2016"],"_links":{"self":[{"href":"https:\/\/www.radians.com.ar\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3025","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.radians.com.ar\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.radians.com.ar\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.radians.com.ar\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.radians.com.ar\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3025"}],"version-history":[{"count":2,"href":"https:\/\/www.radians.com.ar\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3025\/revisions"}],"predecessor-version":[{"id":3027,"href":"https:\/\/www.radians.com.ar\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3025\/revisions\/3027"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.radians.com.ar\/blog\/index.php?rest_route=\/wp\/v2\/media\/4291"}],"wp:attachment":[{"href":"https:\/\/www.radians.com.ar\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3025"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.radians.com.ar\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3025"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.radians.com.ar\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3025"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}