Questo script PowerShell permette di esportare l'elenco dei task schedulati in Windows (Task Scheduler)

PowerShell

Get-ScheduledTask | % {  
	return [pscustomobject]@{
		TaskPath = $_.TaskPath
		TaskName = $_.TaskName
		State = $_.State
		ActionCount = $_.Actions.Count
		Action = $_.Actions.Execute
		TriggerEnabledCount = @($_.Triggers | Where-Object {$true -eq $_.Enabled}).Count
	}
}
se si vuole salvare l'elenco in un file CSV si può usare Export-Csv

PowerShell

Get-ScheduledTask | % {  
	return [pscustomobject]@{
		TaskPath = $_.TaskPath
		TaskName = $_.TaskName
		State = $_.State
		ActionCount = $_.Actions.Count
		Action = $_.Actions.Execute
		TriggerEnabledCount = @($_.Triggers | Where-Object {$true -eq $_.Enabled}).Count
	}
} | Export-Csv $pwd\tasks.csv
un esempio di output è questo

Text

#TYPE System.Management.Automation.PSCustomObject
"TaskPath","TaskName","State","ActionCount","Action","TriggerEnabledCount"
"\","GoogleUpdateTaskMachineCore","Ready","1","C:\Program Files (x86)\Google\Update\GoogleUpdate.exe","2"
"\","GoogleUpdateTaskMachineUA","Ready","1","C:\Program Files (x86)\Google\Update\GoogleUpdate.exe","1"
"\","MicrosoftEdgeUpdateTaskMachineCore","Ready","1","C:\Program Files (x86)\Microsoft\EdgeUpdate\MicrosoftEdgeUpdate.exe","2"
...
Per avere la certezza di elencare tutti i job schedulati, eseguire il comando con elevati privilegi.
Tags:
PowerShell200 Script85 Windows73 Windows Server20
Potrebbe interessarti anche: