Introduction
PowerShell is an automation powerhouse, but some of its tricks remain hidden even from seasoned professionals. One of the most obscure yet insanely powerful techniques is the ability to create scheduled tasks that don’t persist—meaning they run once, execute a task, and vanish without appearing in the Task Scheduler GUI.
This makes them perfect for:
✔ One-time automation tasks
✔ Ephemeral system maintenance jobs
✔ Stealthy execution without persistent records
And the best part? You don’t need admin privileges to pull this off!
How It Works: The “Run-Once & Disappear” Trick
Instead of creating a persistent scheduled task (which appears in Task Scheduler), we use PowerShell’s built-in schtasks.exe to schedule an ephemeral, one-time execution.
Create a Self-Deleting Task
Run this command to create a scheduled task that auto-deletes itself after execution:
schtasks /Create /TN "HiddenTask" /TR "powershell.exe -WindowStyle Hidden -Command {Write-Host 'Task Executed'}" /SC ONCE /ST 00:00 /F /Z
PowerShellWhat This Does:
- Creates a hidden scheduled task named
"HiddenTask" - Runs a PowerShell command in the background (
-WindowStyle Hidden) - Executes only once (
/SC ONCE) - Auto-deletes itself after running (
/Zflag)
Use Cases for Invisible Scheduled Tasks
Running a PowerShell Script at Startup (Without Persistent Task)
Want to execute a startup script once without leaving traces? Just schedule it like this:
schtasks /Create /TN "TempStartupTask" /TR "powershell.exe -ExecutionPolicy Bypass -File C:\Scripts\StartupTask.ps1" /SC ONSTART /F /Z
PowerShellPerfect for:
- Running post-login automation without manual execution
- Ensuring one-time updates or configurations without modifying registry Run keys
- Keeping automation temporary & transient
Scheduling a Task in the Future (No Persistent Record)
Want to run a command in the future (e.g., 10 minutes from now) but don’t want it to persist? Use this:
$FutureTime = (Get-Date).AddMinutes(10).ToString("HH:mm")
schtasks /Create /TN "OneTimeRun" /TR "powershell.exe -Command {Get-Process | Out-File C:\Temp\ProcessList.txt}" /SC ONCE /ST $FutureTime /F /Z
PowerShellWhy is this cool?
- The task will execute only once and disappear automatically.
- No clutter left in Task Scheduler.
- Great for one-off system monitoring or cleanup tasks.
Running Hidden System Maintenance Tasks
Let’s say you need to clean temporary files but don’t want a visible scheduled task in Windows:
schtasks /Create /TN "HiddenCleanup" /TR "powershell.exe -Command {Remove-Item C:\Temp\* -Recurse -Force}" /SC ONCE /ST 03:00 /F /Z
PowerShellBenefits:
- Runs at 03:00 AM, cleans temp files, and disappears.
- No need to remember removing the task manually.
Bonus: Execute a PowerShell Script Without Showing the Console
Want a PowerShell script to run silently with no console window? Modify the schtasks command like this:
schtasks /Create /TN "SilentTask" /TR "powershell.exe -WindowStyle Hidden -File C:\Scripts\HiddenScript.ps1" /SC ONCE /ST 00:00 /F /Z
PowerShell✔ Hides the PowerShell console while running the script.
✔ Perfect for automation scripts that shouldn’t distract users.
Security Considerations
While this is a legitimate automation trick, it can also be abused by malware to execute hidden tasks. To prevent misuse:
- Monitor scheduled tasks with:
schtasks /Query /FO LIST
PowerShellCheck for recently executed tasks:
Get-WinEvent -LogName "Microsoft-Windows-TaskScheduler/Operational" -MaxEvents 50
PowerShellBlock unauthorized scripts via AppLocker or Windows Defender Application Control.
References & Further Reading
- Microsoft Docs:
schtasks.exe - Microsoft Docs:
Get-ScheduledTask
