{"id":353,"date":"2012-09-04T13:44:23","date_gmt":"2012-09-04T17:44:23","guid":{"rendered":"http:\/\/rajdude.com\/blog\/?p=353"},"modified":"2012-09-04T13:46:12","modified_gmt":"2012-09-04T17:46:12","slug":"setting-a-static-ip-using-powershell","status":"publish","type":"post","link":"https:\/\/rajdude.com\/blog\/setting-a-static-ip-using-powershell\/","title":{"rendered":"Setting a static IP using powershell"},"content":{"rendered":"<p>Here is a quick way to set your IP address to a static value:<\/p>\n<pre>$NICs = Get-WMIObject Win32_NetworkAdapterConfiguration -computername . | where{$_.IPEnabled -eq $true -and $_.DHCPEnabled -eq $true} \r\nForeach($NIC in $NICs) { \r\n\u00a0\u00a0\u00a0 $ip = \"10.0.0.151\"\r\n\u00a0\u00a0\u00a0 $gateway = \"10.0.0.1\"\r\n\u00a0\u00a0\u00a0 $subnet = \"255.255.255.0\"\r\n\u00a0\u00a0\u00a0 $dns = \"10.0.0.10\",\"10.0.0.11\"\r\n\u00a0\u00a0\u00a0 $NIC.EnableStatic($ip, $subnet) \r\n\u00a0\u00a0\u00a0 $NIC.SetGateways($gateway) \r\n\u00a0\u00a0\u00a0 $NIC.SetDNSServerSearchOrder($dns) \r\n\u00a0\u00a0\u00a0 $NIC.SetDynamicDNSRegistration(\"FALSE\") \r\n} \r\nIPConfig \/all<\/pre>\n<p>Credits: Original script taken <a href=\"http:\/\/blogs.technet.com\/b\/danstolts\/archive\/2012\/01\/31\/using-powershell-to-get-or-set-networkadapterconfiguration-view-and-change-network-settings-including-dhcp-dns-ip-address-and-more-dynamic-and-static-step-by-step.aspx\" target=\"_blank\">from here<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here is a quick way to set your IP address to a static value: $NICs = Get-WMIObject Win32_NetworkAdapterConfiguration -computername . | where{$_.IPEnabled -eq $true -and $_.DHCPEnabled -eq $true} Foreach($NIC in $NICs) { \u00a0\u00a0\u00a0 $ip = &#8220;10.0.0.151&#8221; \u00a0\u00a0\u00a0 $gateway = &#8220;10.0.0.1&#8221; \u00a0\u00a0\u00a0 $subnet = &#8220;255.255.255.0&#8221; \u00a0\u00a0\u00a0 $dns = &#8220;10.0.0.10&#8221;,&#8221;10.0.0.11&#8243; \u00a0\u00a0\u00a0 $NIC.EnableStatic($ip, $subnet) \u00a0\u00a0\u00a0 $NIC.SetGateways($gateway) \u00a0\u00a0\u00a0 $NIC.SetDNSServerSearchOrder($dns) \u00a0\u00a0\u00a0 $NIC.SetDynamicDNSRegistration(&#8220;FALSE&#8221;) } IPConfig \/all Credits: Original script taken from here<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[48,29],"class_list":["post-353","post","type-post","status-publish","format-standard","hentry","category-itsys","tag-powershell","tag-system-administration"],"_links":{"self":[{"href":"https:\/\/rajdude.com\/blog\/wp-json\/wp\/v2\/posts\/353","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/rajdude.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rajdude.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rajdude.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rajdude.com\/blog\/wp-json\/wp\/v2\/comments?post=353"}],"version-history":[{"count":2,"href":"https:\/\/rajdude.com\/blog\/wp-json\/wp\/v2\/posts\/353\/revisions"}],"predecessor-version":[{"id":356,"href":"https:\/\/rajdude.com\/blog\/wp-json\/wp\/v2\/posts\/353\/revisions\/356"}],"wp:attachment":[{"href":"https:\/\/rajdude.com\/blog\/wp-json\/wp\/v2\/media?parent=353"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rajdude.com\/blog\/wp-json\/wp\/v2\/categories?post=353"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rajdude.com\/blog\/wp-json\/wp\/v2\/tags?post=353"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}