You could replace it all with:
function Get-ScheduledTask {
end {
SCHTASKS.EXE /QUERY /FO CSV | ConvertFrom-Csv
}
}
Comments: You are right, but the function has been written in this way for two reasons : 1- The NoteProperty "TaskName" and "TaskStatus" depends on OS localization. For example, a French Windows version will return "Nom de la tâche" and "État", and a US version will return "TaskName" and "Status" To be usable in any OS localization, the split is used to retrieve status and taskname column name. 2- To interact with Stop and Start Functions (with the NoteProperty generated)
function Get-ScheduledTask {
end {
SCHTASKS.EXE /QUERY /FO CSV | ConvertFrom-Csv
}
}
Comments: You are right, but the function has been written in this way for two reasons : 1- The NoteProperty "TaskName" and "TaskStatus" depends on OS localization. For example, a French Windows version will return "Nom de la tâche" and "État", and a US version will return "TaskName" and "Status" To be usable in any OS localization, the split is used to retrieve status and taskname column name. 2- To interact with Stop and Start Functions (with the NoteProperty generated)