{"id":580,"date":"2015-03-11T14:18:29","date_gmt":"2015-03-11T14:18:29","guid":{"rendered":"http:\/\/giraffeit.com\/?p=580"},"modified":"2016-09-10T10:23:39","modified_gmt":"2016-09-10T10:23:39","slug":"statictodhcpdns","status":"publish","type":"post","link":"https:\/\/giraffeit.com\/index.php\/2015\/03\/11\/statictodhcpdns\/","title":{"rendered":"Powershell : remote machines static dns to DHCP"},"content":{"rendered":"<p>This will read an input file , and using the WMI object change any statically assigned DNS to DHCP.<\/p>\n<p>&nbsp;<\/p>\n<p># grabs the ListofMachines from the CSV<br \/>\n$ListofMachines=Get-Content &#8220;c:tempmachines.csv&#8221;<br \/>\n# loop starts here<br \/>\nforeach ($machine in $ListofMachines)<br \/>\n{<br \/>\n#Performs a release ( if needed ! use with care remotely ! )<br \/>\n#Get-WmiObject -Class Win32_NetworkAdapterConfiguration -ComputerName $machine | Where { $_.IpEnabled -eq $true -and $_.DhcpEnabled -eq $true} | ForEach-Object -Process {$_.ReleaseDHCPLease()}<br \/>\n# query the $machine that has the DHCP enabled adapter and performs the renewal<br \/>\n$wmi = Get-WmiObject win32_networkadapterconfiguration -computerName $machine -filter &#8220;ipenabled =&#8217;true'&#8221;;<br \/>\n$wmi.EnableDHCP();<br \/>\n$wmi.SetDNSServerSearchOrder();<\/p>\n<p>Get-WmiObject -Class Win32_NetworkAdapterConfiguration -ComputerName $machine | Where { $_.IpEnabled -eq $true -and $_.DhcpEnabled -eq $true} | ForEach-Object -Process {ipconfig \/flushdns}<\/p>\n<p>}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This will read an input file , and using the WMI object change any statically assigned DNS to DHCP. &nbsp; # grabs the ListofMachines from the CSV $ListofMachines=Get-Content &#8220;c:tempmachines.csv&#8221; # loop starts here foreach ($machine in $ListofMachines) { #Performs a release ( if needed ! use with care remotely ! ) #Get-WmiObject -Class Win32_NetworkAdapterConfiguration -ComputerName &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/giraffeit.com\/index.php\/2015\/03\/11\/statictodhcpdns\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Powershell : remote machines static dns to DHCP&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":205,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"class_list":["post-580","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-bog"],"_links":{"self":[{"href":"https:\/\/giraffeit.com\/index.php\/wp-json\/wp\/v2\/posts\/580","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/giraffeit.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/giraffeit.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/giraffeit.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/giraffeit.com\/index.php\/wp-json\/wp\/v2\/comments?post=580"}],"version-history":[{"count":1,"href":"https:\/\/giraffeit.com\/index.php\/wp-json\/wp\/v2\/posts\/580\/revisions"}],"predecessor-version":[{"id":692,"href":"https:\/\/giraffeit.com\/index.php\/wp-json\/wp\/v2\/posts\/580\/revisions\/692"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/giraffeit.com\/index.php\/wp-json\/wp\/v2\/media\/205"}],"wp:attachment":[{"href":"https:\/\/giraffeit.com\/index.php\/wp-json\/wp\/v2\/media?parent=580"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/giraffeit.com\/index.php\/wp-json\/wp\/v2\/categories?post=580"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/giraffeit.com\/index.php\/wp-json\/wp\/v2\/tags?post=580"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}