Entrinsec.Powershell.Scheduling (1.15.78)
Installation
dotnet nuget add source --name Entrinsec dotnet add package --source Entrinsec --version 1.15.78 Entrinsec.Powershell.SchedulingAbout this package
Functions for scheduling launching of apps, scripts and other similar activities.
Entrinsec.Powershell.Scheduling
PowerShell module for managing Windows Scheduled Tasks with consistent logging and error handling.
Features
- Remove-ScheduledTaskIfExists: Safely remove scheduled tasks with automatic fallback to
schtasks.exeif ScheduledTasks module is unavailable - New-EntrinsecScheduledTask: Create scheduled tasks with common trigger types (Once, Daily, Hourly, AtLogon, AtStartup)
- Get-EntrinsecScheduledTasks: List scheduled tasks with optional filtering
- Copy-EntrinsecScheduledTask: Duplicate existing scheduled tasks with optional user/privilege changes
Compatibility
This module automatically detects the available PowerShell environment:
- PowerShell 5.1+ / PowerShell 7+: Uses native ScheduledTasks cmdlets
- Older PowerShell or missing ScheduledTasks module: Falls back to
schtasks.execommand-line utility for Remove operations
Note: When using -User INTERACTIVE, tasks are created with LogonType Interactive and will run as the current logged-on user.
Installation
Using NuGet
nuget install Entrinsec.Powershell.SCHEDULING
Direct Import
Import-Module 'C:\ADO\COMMON\Modules\Entrinsec\BaGetter\Entrinsec.Powershell.Scheduling' -Force
Requirements
- PowerShell 5.1 or higher (recommended for full functionality)
- Administrator privileges for task creation/deletion
Entrinsec.Powershell.Commonmodule (for logging functions)
Usage Examples
Remove a Scheduled Task
Remove-ScheduledTaskIfExists -TaskName "MyTask"
Create a Scheduled Task (Hourly)
New-EntrinsecScheduledTask -TaskName "MyHourlyTask" `
-ExecutePath "C:\Windows\System32\wscript.exe" `
-Arguments "//B C:\Scripts\MyScript.vbs" `
-TriggerType Hourly `
-User INTERACTIVE `
-RunWithHighestPrivileges `
-Force
Create a Scheduled Task (At Logon)
New-EntrinsecScheduledTask -TaskName "OpenAdminCMD" `
-ExecutePath "C:\Windows\System32\cmd.exe" `
-TriggerType AtLogon `
-User INTERACTIVE `
-RunWithHighestPrivileges `
-Force
List Scheduled Tasks
Get-EntrinsecScheduledTasks -NameLike "Choc*"
More information available at entrinsec.com
Release notes are contained in the package in the RELEASE_NOTES.md file.