Powershell ā Get Domain Controllers Scheduled Task
Real quick post for the day. This script is designed to enumerate every Domain Controller in a forest and retrieve all the scheduled task. Note this script will not work if you run it from Windows 2008 R2 or Windows 7. You would need to change the script to use get-wmiobject instead.
$default_log = $env:userprofile + '\Documents\dc_scheduletask_report.csv'
Import-Module activedirectory
((get-adforest).domains | get-addomain).ReplicaDirectoryServers | foreach {Get-Scheduledtask -CimSession $_ | foreach{$_taskpath = $_.taskpath;$_taskname =$_.taskname; $_taskstate=$_.state;$_.actions | select `
@{name='DC';expression={$_.PSComputerName}}, `
@{name='TaskName';expression={$_taskname}}, `
@{name='TaskPath';expression={$_taskPath}}, `
@{name='State';expression={$_taskstate}}, `
execute, arguments, workingdirectory | export-csv $default_log -append -NoTypeInformation
}}
open the results in excel.
Select all the columns
Select Insert and Pivot Table
Select OK
In the pivot Fields drag the field down into the areas like this:
There is now a nice little report.
Look for instances where the grand total does not contain the number of all the DCās in the forest.
Go and investigate the differences. I hope you find this useful. Have a good day.
-Chad