Created
November 4, 2016 00:24
-
-
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 file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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