Question

IPconfig /flushdns Worklet Policy running in a constant 5 min loop

  • 19 April 2022
  • 1 reply
  • 168 views

Badge

Hi All, 

 

Is there a way to make a policy Worklet (already setup) for Ipconfig /flushdns run constantly on like a 5 minute loop for 1000 PC’s. It currently looks like this below. I am moving a Home drive Host VM server to Azure Cloud which will have an IP change and we will change DNS record, and want to minimize downtime.

Evaluation Code

Exit 1

 

Remedial Code

Ipconfig /flushdns


1 reply

Userlevel 5
Badge +1

Might be easier to update the DNS records TTL to five seconds so clients have to reach out. Then after cut-over re-adjust to something more appropriate. 

 

Dropping this in a worklet would enable a task to flush dns every minute (lowest time interval accepted) for one hour.

$TaskStartTime = [datetime]::Now.AddSeconds(10)
$SchedService = New-Object -ComObject Schedule.Service
$SchedService.Connect()
$Task = $SchedService.NewTask(0)
$Task.RegistrationInfo.Description = 'Flush DNS'
$Task.Settings.Enabled = $true
$Task.Settings.AllowDemandStart = $true
$Task.Settings.WakeToRun = $true
$trigger = $Task.triggers.Create(1) # https://docs.microsoft.com/en-us/windows/win32/taskschd/triggercollection-create
$trigger.StartBoundary = $TaskStartTime.ToString("yyyy-MM-dd'T'HH:mm:ss")
$trigger.Repetition.Duration = "PT1H" # do this for 1 hour
$trigger.Repetition.Interval = "PT1M" # every 1 minute
$trigger.Enabled = $true
$action = $Task.Actions.Create(0)
$action.Path = "ipconfig"
$action.Arguments = "/flushdns"
$taskFolder = $SchedService.GetFolder('\')
$taskFolder.RegisterTaskDefinition("Flush-DNS", $Task , 6, 'SYSTEM', $null, 4) | out-null

 

Reply