POWERSHELLUpdated Jul 6, 2026 · 4 min read
Update a scheduled task that uses a gMSA
Modify an existing task action without knowing—or needing—the managed service account password.
Recommended approach
Retrieve the existing task, replace only its action, and preserve the principal and trigger definitions.
$task = Get-ScheduledTask -TaskName 'Nightly Maintenance'
$action = New-ScheduledTaskAction `
-Execute 'PowerShell.exe' `
-Argument '-NoProfile -File C:\Ops\Nightly-Maintenance.ps1'
Set-ScheduledTask -InputObject $task -Action $action
Validation
Start-ScheduledTask -TaskName 'Nightly Maintenance'
Get-ScheduledTaskInfo -TaskName 'Nightly Maintenance'
[!WARNING] Do not recreate the task unless necessary. Doing so can silently replace the existing gMSA principal or security options.