Skip to content

Instantly share code, notes, and snippets.

@PlagueHO
Last active October 22, 2016 19:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PlagueHO/f3215ef69a5bacbace96bc6600e36831 to your computer and use it in GitHub Desktop.
Save PlagueHO/f3215ef69a5bacbace96bc6600e36831 to your computer and use it in GitHub Desktop.
Create a Scheduled Task to Validate the DNS using OVF
$Cred = Get-Credential -Message 'User to run task as'
$Action = New-ScheduledTaskAction `
–Execute 'PowerShell.exe' `
-Argument '-WindowStyle Hidden -Command "Import-Module ValidateDNS; Invoke-ValidateDNS;"'
$Trigger = New-ScheduledTaskTrigger `
-Once `
-At (Get-Date -Hour 0 -Minute 0 -Second 0) `
-RepetitionInterval (New-TimeSpan -Minutes 60) `
-RepetitionDuration ([System.TimeSpan]::MaxValue)
$Task = New-ScheduledTask `
-Description 'Validate DNS' `
-Action $Action `
-Trigger $Trigger
Register-ScheduledTask `
-TaskName 'Validate DNS' `
-InputObject $Task `
-User $Cred.UserName `
-Password $Cred.GetNetworkCredential().Password
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment