{"id":929,"date":"2016-04-27T17:30:58","date_gmt":"2016-04-27T22:30:58","guid":{"rendered":"http:\/\/www.gamescheat.ca\/?p=929"},"modified":"2019-09-04T19:57:39","modified_gmt":"2019-09-05T00:57:39","slug":"change-the-ip-address-of-a-windows-servers-with-powershell-script","status":"publish","type":"post","link":"http:\/\/www.gamescheat.ca\/?p=929","title":{"rendered":"Change the IP address of a Windows servers with VMware PowerCLI script"},"content":{"rendered":"<p>VMware vSphere PowerCLI script to change the IP addresses of Windows servers.  <\/p>\n<blockquote><p>$TranscriptFile = \u201c.\\change-ip-2.txt\u201d<br \/>\n#Stop-Transcript<br \/>\nStart-Transcript -Path $TranscriptFile<\/p>\n<p>$windowsID = \u201cadministrator\u201d<br \/>\n$windowsPassword = \u201cMyPassword\u201d<\/p>\n<p>Function Set-WinVMIP ($VM, $IP, $SNM, $gateway){<\/p>\n<p> $nics = Get-VMGuestNetworkInterface -VM $VM -GuestUser $windowsID -GuestPassword $windowsPassword | ?{$_.ip -ne $null}<\/p>\n<div style=\"float: right;\"><div style=\"margin: 15px 15px 15px 15px\";><script type=\"text\/javascript\"><!--\ngoogle_ad_client = \"pub-3319935785736004\";\ngoogle_alternate_color = \"FFFFFF\";\ngoogle_ad_width = 300;\ngoogle_ad_height = 250;\ngoogle_ad_format = \"300x250_as\";\ngoogle_ad_type = \"text_image\";\ngoogle_ad_channel =\"\";\ngoogle_color_border = \"cccccc\";\ngoogle_color_link = \"cc0000\";\ngoogle_color_bg = \"ffffff\";\ngoogle_color_text = \"000000\";\ngoogle_color_url = \"008000\";\n\/\/--><\/script>\n<script type=\"text\/javascript\"\n  src=\"http:\/\/pagead2.googlesyndication.com\/pagead\/show_ads.js\">\n<\/script><\/div><\/div><p> Write-Host \u201cChanging IP for $VM to $IP\u201d -BackgroundColor DarkBlue<\/p>\n<p>Set-VMGuestNetworkInterface -vmguestnetworkinterface $nics -Ip $IP -Netmask $SNM -Gateway $gateway -Dns $dns1,$dns2 -GuestUser $windowsID -GuestPassword $windowsPassword<\/p>\n<p>  write-host \u201c+++++++++++++++++++++++\u201d<br \/>\n}<\/p>\n<p>#Connect-VIServer localhost<\/p>\n<p>$data = \u201c.\/IP-LIST2.csv\u201d<br \/>\n$list = import-csv $data<\/p>\n<p>foreach ($line in $list)<br \/>\n{<\/p>\n<p>$VM = $line.VM<br \/>\n$IP = $line.IP<br \/>\n$SNM = \u201c255.255.255.0\u201d<br \/>\n$gateway = \u201c192.168.0.1\u201d<br \/>\n$nic = $line.Name<br \/>\n$dns1 = \u201c192.168.0.11\u201d<br \/>\n$dns2 = \u201c192.168.0.12\u201d<\/p>\n<p>Set-WinVMIP $VM $IP $SNM $gateway<\/p>\n<p>}<\/p>\n<p>Get-Date<br \/>\nStop-Transcript<br \/>\nInvoke-Item $TranscriptFile<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>VMware vSphere PowerCLI script to change the IP addresses of Windows servers. $TranscriptFile = \u201c.\\change-ip-2.txt\u201d #Stop-Transcript Start-Transcript -Path $TranscriptFile $windowsID = \u201cadministrator\u201d $windowsPassword = \u201cMyPassword\u201d Function Set-WinVMIP ($VM, $IP, $SNM, $gateway){ $nics = Get-VMGuestNetworkInterface -VM $VM -GuestUser $windowsID -GuestPassword $windowsPassword&hellip;<\/p>\n<p class=\"more-link-p\"><a class=\"more-link\" href=\"http:\/\/www.gamescheat.ca\/?p=929\">Read more &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[13],"tags":[84],"_links":{"self":[{"href":"http:\/\/www.gamescheat.ca\/index.php?rest_route=\/wp\/v2\/posts\/929"}],"collection":[{"href":"http:\/\/www.gamescheat.ca\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.gamescheat.ca\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.gamescheat.ca\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.gamescheat.ca\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=929"}],"version-history":[{"count":3,"href":"http:\/\/www.gamescheat.ca\/index.php?rest_route=\/wp\/v2\/posts\/929\/revisions"}],"predecessor-version":[{"id":932,"href":"http:\/\/www.gamescheat.ca\/index.php?rest_route=\/wp\/v2\/posts\/929\/revisions\/932"}],"wp:attachment":[{"href":"http:\/\/www.gamescheat.ca\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=929"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.gamescheat.ca\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=929"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.gamescheat.ca\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=929"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}