Code:
$objDomain = New-Object System.DirectoryServices.DirectoryEntry("LDAP://OU=Servers,dc=<doman>,dc=<local>")
$objSearcher = New-Object System.DirectoryServices.DirectorySearcher
$strFilter = "(objectCategory=Computer)"
$objSearcher.SearchRoot = $objDomain
$objSearcher.PageSize = 1000
$objSearcher.Filter = $strFilter
$objSearcher.SearchScope = "Subtree"
$colResults = $objSearcher.FindAll()
foreach ($objResult in $colResults)
{
$servername = $objResult.Properties
$servername = "TMCAPP04"
$schedule = new-object -com("Schedule.Service")
$schedule.connect($servername.name)
$tasks = $schedule.getfolder("\").gettasks(0)
$tasks |select name, lasttaskresult, lastruntime, nextruntime
}
This does not display expected data, it looks like it is showing a CLSID of something with the dates being wrong as well as the lastresult data. Works fine with the following. I am a powershell newbie, but I have cut my teeth with vbscript. I am just trying to learn powershell.
Code:
$servername = "<servername>"
$schedule = new-object -com("Schedule.Service")
$schedule.connect($servername)
$tasks = $schedule.getfolder("\").gettasks(0)
$tasks |select name, lasttaskresult, lastruntime, nextruntime
Windows Haiku:
Serious error.
All shortcuts have disappeared.
Screen. Mind. Both are blank.