# grabs the ListofMachines from the CSV
$ListofMachines=Get-Content “c:tempmachines.csv”
# loop starts here
foreach ($machine in $ListofMachines)
{
#Performs a release ( if needed ! use with care remotely ! )
#Get-WmiObject -Class Win32_NetworkAdapterConfiguration -ComputerName $machine | Where { $_.IpEnabled -eq $true -and $_.DhcpEnabled -eq $true} | ForEach-Object -Process {$_.ReleaseDHCPLease()}
# query the $machine that has the DHCP enabled adapter and performs the renewal
Get-WmiObject -Class Win32_NetworkAdapterConfiguration -ComputerName $machine | Where { $_.IpEnabled -eq $true -and $_.DhcpEnabled -eq $true} | ForEach-Object -Process {$_.RenewDHCPLease()}
Get-WmiObject -Class Win32_NetworkAdapterConfiguration -ComputerName 10.130.54.53 | Where { $_.IpEnabled -eq $true -and $_.DhcpEnabled -eq $true} | ForEach-Object -Process {ipconfig /flushdns}
#log for Output!
write-output “$machine has had IP renewed ” |out-file -filepath “c:tempresultsofDHCPLease04032015.csv” -append
}