17 lines
557 B
PowerShell
17 lines
557 B
PowerShell
param(
|
|
[string]$TaskName = "FutureMap-InsightsHub-Daily",
|
|
[string]$StartTime = "06:00"
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
$scriptDirectory = Split-Path -Parent $MyInvocation.MyCommand.Path
|
|
$runner = Join-Path $scriptDirectory "run_daily.ps1"
|
|
$taskCommand = 'powershell.exe -NoProfile -ExecutionPolicy Bypass -File "' + $runner + '"'
|
|
|
|
& schtasks.exe /Create /TN $TaskName /SC DAILY /ST $StartTime /TR $taskCommand /F
|
|
if ($LASTEXITCODE -ne 0) {
|
|
throw "Unable to create scheduled task $TaskName."
|
|
}
|
|
|
|
& schtasks.exe /Query /TN $TaskName /V /FO LIST
|