Skip to content

Instantly share code, notes, and snippets.

@rohit-lakhanpal
Created November 4, 2016 00:24
Show Gist options
  • Save rohit-lakhanpal/148e47bdcdea02ba5fa8792736e6478c to your computer and use it in GitHub Desktop.
Save rohit-lakhanpal/148e47bdcdea02ba5fa8792736e6478c to your computer and use it in GitHub Desktop.
This powershell script is able to invoke another powershell script every 90 seconds & pipe the output to a file
# This function generates a new filename based on the current datetime
function GenerateFileNamePerHour
{
# Store the current date in a variable
$cDate = Get-Date
$val = ("{0}_{1}_{2}-{3}00HRS.log" -f $cDate.Day, $cDate.Month, $cDate.Year, $cDate.Hour)
return $val
}
# This script will run till the 328th day of the year
while((Get-Date).DayOfYear -le 328)
{
.\YourScript.ps1 | Out-File "$(GenerateFileNamePerHour)" -Append
# Script continues every 90 seconds
Start-Sleep -seconds 90
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment