Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Define variables
- $taskName = "Update Power BI Gateway"
- $taskActionPath = "powershell.exe"
- $taskActionArguments = "-File C:\Path\To\Update-PowerBIGateway.ps1"
- $taskTrigger = New-ScheduledTaskTrigger -Monthly -DaysOfMonth 1 -At 2:00AM
- $taskPrincipal = New-ScheduledTaskPrincipal -UserId "SYSTEM" -LogonType ServiceAccount -RunLevel Highest
- $taskSettings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -StartWhenAvailable
- # Define the action for the scheduled task
- $taskAction = New-ScheduledTaskAction -Execute $taskActionPath -Argument $taskActionArguments
- # Create the scheduled task
- $task = New-ScheduledTask -Action $taskAction -Principal $taskPrincipal -Trigger $taskTrigger -Settings $taskSettings
- # Register the scheduled task
- Register-ScheduledTask -TaskName $taskName -InputObject $task -Force
- Write-Host "Scheduled task '$taskName' has been created."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement