
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-22-2019 05:25 PM
I found a way to do a report in powershell but it would be cleaner and better in LANSweeper for sure.
Here is the powershell
[cmdletbinding()]
param (
[parameter(ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)]
[string[]] $ComputerName = $env:computername,
## Get-ADComputer -Filter * | Select -Expand Name
[string] $TaskName
)
#function to get all scheduled task folder details.
function Get-TaskSubFolders {
[cmdletbinding()]
param (
$FolderRef
)
$ArrFolders = @()
$folders = $folderRef.getfolders(1)
if($folders) {
foreach ($folder in $folders) {
$ArrFolders = $ArrFolders + $folder
if($folder.getfolders(1)) {
Get-TaskSubFolders -FolderRef $folder
}
}
}
return $ArrFolders
}
#MAIN
#$ComputerName = Get-ADComputer -Filter * | Select -Expand Name
foreach ($Computer in $ComputerName) {
$SchService = New-Object -ComObject Schedule.Service
$SchService.Connect($Computer)
$Rootfolder = $SchService.GetFolder("\")
$folders = @($RootFolder)
$folders += Get-Tasksubfolders -FolderRef $RootFolder
foreach($Folder in $folders) {
$Tasks = $folder.gettasks(1)
foreach($Task in $Tasks) {
$OutputObj = New-Object -TypeName PSobject
$OutputObj | Add-Member -MemberType NoteProperty -Name ComputerName -Value $Computer
$OutputObj | Add-Member -MemberType NoteProperty -Name TaskName -Value $Task.Name
$OutputObj | Add-Member -MemberType NoteProperty -Name TaskFolder -Value $Folder.path
$OutputObj | Add-Member -MemberType NoteProperty -Name IsEnabled -Value $task.enabled
$OutputObj | Add-Member -MemberType NoteProperty -Name LastRunTime -Value $task.LastRunTime
$OutputObj | Add-Member -MemberType NoteProperty -Name LastTaskResult -Value $task.LastTaskResult
$OutputObj | Add-Member -MemberType NoteProperty -Name NextRunTime -Value $task.NextRunTime
$OutputObj | Add-Member -MemberType NoteProperty -Name State -Value $task.State
$OutputObj | Add-Member -MemberType NoteProperty -Name TaskFolderPath -Value $task.Path
if($TaskName) {
if($Task.Name -eq $TaskName) {
$OutputObj
}
} else {
$OutputObj
}
}
}
}
Save it as a file called findscheduledtasks.ps1
then you can run it in powershell (I used an administrative powershell just in case)
.\findscheduledtasks.ps1 | ConvertTo-Html -Property ComputerName,TaskName,Folder,IsEnabled,State,LastRunTime,LastTaskResult,NextRunTime, TaskFolderPath -Head $Header | Out-File -FilePath scheduledtasks.html
The Output is a file in your folder called "Scheduledtasks.html" open in your browser and you get a table from your local system scheduled tasks.
uncomment this line "#$ComputerName = Get-ADComputer -Filter * | Select -Expand Name" and it will scan all systems from AD that you have access too, that could take a while.
WARNING, I cobbled together several scripts and examples I found on the web to make this work. I am not very good at Powershell and even worse at HTML, there is a lot to improve upon, which is why I was thinking LS could do this
Forum Admins, if you don't like this post or feel it is miscategorized etc, feel free to move/delete it and let me know.
Thanks
- Labels:
-
Report Center

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-16-2020 09:23 AM
- Run the following simple PowerShell oneliner (eg. using deployment):
Get-ScheduledTask -TaskPath "\" | Get-ScheduledTaskInfo | % {$str = "TaskName : " ;$str += $_.TaskName; $str += " ; Lastruntime : ";$str += $_.Lastruntime; $str += " ; LastTaskResult : "; $str += $_.LastTaskResult; EventCreate /so SchedTask /L Application /T Error /ID 1000 /D $str}
- Rescan your asset(s) and check the Event log tab
We didn't create any report yet as we only use this workaround 'on the fly' to collect specific information.
PS. instead of using the deployment feature we use McAfee ePO to run PowerShell or other scripts. No credentials or other complex configuration needed. If you want to collect the output from your scripts you can parse it either to a (custom) registry key or to the Event Log.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-15-2020 05:54 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2019 07:45 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2019 09:21 AM
