{"id":2886,"date":"2015-08-28T00:03:02","date_gmt":"2015-08-28T03:03:02","guid":{"rendered":"http:\/\/www.radians.com.ar\/blog\/?p=2886"},"modified":"2018-01-16T17:11:54","modified_gmt":"2018-01-16T20:11:54","slug":"como-configurar-una-nic-con-powershell-en-windows-server-2012-r2-howto","status":"publish","type":"post","link":"https:\/\/www.radians.com.ar\/blog\/?p=2886","title":{"rendered":"Como configurar una NIC con PowerShell en Windows Server 2012 R2 {HowTo}"},"content":{"rendered":"<p align=\"justify\"><a href=\"http:\/\/www.radians.com.ar\/Articulos\/Images2014\/ComoconfigurarunaNICconPowerShellenWindo_12356\/1092296.gif\"><img loading=\"lazy\" decoding=\"async\" title=\"www.radians.com.ar\" style=\"border-top: 0px; border-right: 0px; border-bottom: 0px; margin-left: 0px; border-left: 0px; display: inline; margin-right: 0px\" border=\"0\" alt=\"www.radians.com.ar\" src=\"http:\/\/www.radians.com.ar\/Articulos\/Images2014\/ComoconfigurarunaNICconPowerShellenWindo_12356\/1092296_thumb.gif\" width=\"150\" align=\"left\" height=\"125\" \/><\/a> Hoy quer\u00eda compartir con ustedes estos tips en PowerShell, todo surgi\u00f3 como una consulta a como configurar algo en un servidor el cual se acced\u00eda de forma remota y el refresh de la pantalla era muy lento por lo cual configurarla era bastante tedioso. <\/p>\n<p align=\"justify\">Como sobran Microsoft proporciona soporte nativo de Windows PowerShell para realizar tareas de configuraci\u00f3n de NIC. Tambi\u00e9n podemos ver todos los cmdlets disponibles para realizar tareas de networking en el sitio oficial de Microsoft: <a href=\"https:\/\/technet.microsoft.com\/en-us\/library\/jj717268.aspx\">TechNet: Windows PowerShell Cmdlets for Networking<\/a>.<\/p>\n<p align=\"justify\">Un escenario de uso t\u00edpico es configurar los valores de TCP\/IP, por lo que podemos aprovechar los cmdlets de TCP\/IP que est\u00e1n disponibles en el m\u00f3dulo NetAdapter.<\/p>\n<h4 align=\"justify\">HowTo\u2026<\/h4>\n<ul>\n<li>\n<div align=\"justify\">Importamos el m\u00f3dulo NetAdapter. Este paso es opcional, ya que con Windows PowerShell 3.0, la nueva funci\u00f3n de m\u00f3dulo de carga autom\u00e1tica se encarga de esto. Si es valido para versiones anteriores        <br \/><font color=\"#ff0000\" face=\"OCR A Extended\">Import-Module NetAdapter<\/font><\/div>\n<\/li>\n<li>\n<div align=\"justify\">Para seleccionar el adaptador de red que desea configurar.        <br \/><font color=\"#ff0000\" face=\"OCR A Extended\">Get-NetAdapter -Name Ethernet3<\/font><\/div>\n<\/li>\n<\/ul>\n<p align=\"justify\"><a href=\"http:\/\/www.radians.com.ar\/Articulos\/Images2014\/ComoconfigurarunaNICconPowerShellenWindo_12356\/WindowsServer2012R220150828160059.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\/ComoconfigurarunaNICconPowerShellenWindo_12356\/WindowsServer2012R220150828160059_thumb.png\" width=\"544\" height=\"256\" \/><\/a><\/p>\n<ul>\n<li>\n<div align=\"justify\">Para desactivar DHCP        <br \/><font color=\"#ff0000\" face=\"OCR A Extended\">Get-NetAdapter -Name Ethernet3 | Set-NetIPInterface -DHCP Disabled<\/font> <\/div>\n<\/li>\n<li>\n<div align=\"justify\">Para configurar la direcci\u00f3n IP y la puerta de enlace predeterminada        <br \/><font color=\"#ff0000\" face=\"OCR A Extended\">Get-NetAdapter -Name Ethernet3 | New-NetIPAddress -AddressFamily IPv4 -IPAddress 10.59.2.11 -PrefixLength 24 -Type Unicast -DefaultGateway 10.59.2.254          <br \/><\/font>Aqu\u00ed le estamos asignando a la NIC llamada Ethernet3 la IP 10.59.2.11, subnet 255.255.255.0 y el gateway 10.59.2.254<\/div>\n<\/li>\n<li>\n<div align=\"justify\">Para&#160; asignarle los DNS (primarios y secundarios), podemos hacerlo con la siguiente entrada:        <br \/><font color=\"#ff0000\" face=\"OCR A Extended\">Set-DnsClientServerAddress -InterfaceAlias Ethernet3 -ServerAddresses 10.59.0.1, 10.59.0.2<\/font><\/div>\n<\/li>\n<\/ul>\n<p align=\"justify\"><a href=\"http:\/\/www.radians.com.ar\/Articulos\/Images2014\/ComoconfigurarunaNICconPowerShellenWindo_12356\/WindowsServer2012R220150828160311.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\/ComoconfigurarunaNICconPowerShellenWindo_12356\/WindowsServer2012R220150828160311_thumb.png\" width=\"544\" height=\"311\" \/><\/a> <a href=\"http:\/\/www.radians.com.ar\/Articulos\/Images2014\/ComoconfigurarunaNICconPowerShellenWindo_12356\/WindowsServer2012R220150828160323.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\/ComoconfigurarunaNICconPowerShellenWindo_12356\/WindowsServer2012R220150828160323_thumb.png\" width=\"454\" height=\"506\" \/><\/a>&#160; <a href=\"http:\/\/www.radians.com.ar\/Articulos\/Images2014\/ComoconfigurarunaNICconPowerShellenWindo_12356\/WindowsServer2012R220150828160421.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\/ComoconfigurarunaNICconPowerShellenWindo_12356\/WindowsServer2012R220150828160421_thumb.png\" width=\"544\" height=\"314\" \/><\/a>&#160; <\/p>\n<p align=\"justify\">Esto tambi\u00e9n lo podr\u00edamos haber realizado de la vieja forma con el comando <font color=\"#ff0000\" face=\"oc\">netsh.exe<\/font>. <\/p>\n<ul>\n<li>\n<div align=\"justify\"><font color=\"#ff0000\" face=\"OCR A Extended\">netsh interface ip set address name=&quot;Ethernet3&quot; static 10.59.2.11 255.255.255.0 10.59.2.254 1 <\/font><\/div>\n<\/li>\n<li>\n<div align=\"justify\"><font color=\"#ff0000\" face=\"OCR A Extended\">netsh interface ip set dns &quot;Ethernet3&quot; static 10.59.0.1, 10.59.0.2<\/font><\/div>\n<\/li>\n<\/ul>\n<p align=\"justify\">Si quieren ver todas las opciones de configuraci\u00f3n de este comando, les recomiendo ver el siguiente link: <a href=\"https:\/\/technet.microsoft.com\/en-us\/library\/cc725935(v=ws.10).aspx\">TechNet: Netsh Technical Reference<\/a><\/p>\n<ul>\n<li>\n<div align=\"justify\">Si quisieramos renombrar nuestra NIC, podemos hacerlo con los siguiente:        <br \/><font color=\"#ff0000\" face=\"OCR A Extended\">Rename-NetAdapter -Name &quot;Ethernet3&quot; &quot;Production Ethernet\u201d<\/font><\/div>\n<\/li>\n<li>\n<div align=\"justify\">Para ver las propiedades avanzadas: <font color=\"#ff0000\" face=\"OCR A Extended\">Get-NetAdapterAdvancedProperty P*1<\/font><\/div>\n<\/li>\n<li>\n<div align=\"justify\">Para reiniciar el dispositivo <font color=\"#ff0000\" face=\"OCR A Extended\"><b>Restart-NetAdapter (NIC Name)<\/b><\/font><\/div>\n<\/li>\n<\/ul>\n<p align=\"justify\"><a href=\"http:\/\/www.radians.com.ar\/Articulos\/Images2014\/ComoconfigurarunaNICconPowerShellenWindo_12356\/WindowsServer2012R220150828160518.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\/ComoconfigurarunaNICconPowerShellenWindo_12356\/WindowsServer2012R220150828160518_thumb.png\" width=\"544\" height=\"476\" \/><\/a><\/p>\n<ul>\n<li>\n<div align=\"justify\">Para tener un detalle de la configuraci\u00f3n del dispositivo <font color=\"#ff0000\" face=\"OCR A Extended\"><b>Get-NetAdapter -Name ethernet | fl *<\/b><\/font><\/div>\n<\/li>\n<\/ul>\n<p align=\"justify\">Obviamente esto nos abre un mont\u00f3n de posibilidades, ya que tambi\u00e9n dependiendo del rol de nuestro servidor tendremos mayor cantidad de opciones. Es decir, si el servidor por ejemplo esta configurado como Server de virtualizaci\u00f3n Hyper-V o mejor aun, un cl\u00faster de virtualizaci\u00f3n Hyper-V, .no solo podre configurar las NICs para un Nic Teaming por medio de PowerShell, sino que tambi\u00e9n podre configurar el virtualswitch, el heartbeat, liveMigration, y todas aquellas opciones de Hyper-V. Tambi\u00e9n pueden ver as detalle de estos comandos en: <a href=\"https:\/\/technet.microsoft.com\/en-us\/library\/hh848559.aspx\">TechNet: Hyper-V Cmdlets<\/a><\/p>\n<p align=\"justify\">Espero que les sea de inter\u00e9s y utilidad. Saludos, Roberto Di Lello.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hoy quer\u00eda compartir con ustedes estos tips en PowerShell, todo surgi\u00f3 como una consulta a&#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":[11,158,281,4,6,279,69,297],"tags":[192,304,195,243],"class_list":["post-2886","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-2008-r2","category-windows-server-2012","category-281","category-scripting","category-tools","category-windows-10","category-windows-7","category-windows-8","tag-script","tag-windows-10","tag-windows-server-2008-r2","tag-windows-server-2012-r2"],"_links":{"self":[{"href":"https:\/\/www.radians.com.ar\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2886","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=2886"}],"version-history":[{"count":2,"href":"https:\/\/www.radians.com.ar\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2886\/revisions"}],"predecessor-version":[{"id":2888,"href":"https:\/\/www.radians.com.ar\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2886\/revisions\/2888"}],"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=2886"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.radians.com.ar\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2886"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.radians.com.ar\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2886"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}