Fix 2008R2 scheduled tasks

[ps]
Function Change-ScheduledTask {
Param($XMLIn)
$ShortDate = [regex]"(?<shortdate>[0-9]{4}[/.-](?:1[0-2]|0[1-9])[/.-](?:3[01]|[12][0-9]|0[1-9])T(?:2[0-3]|[01][0-9])[:.][0-5][0-9][:.][0-5][0-9])(?<digits>\.\d*)"

foreach ($line in $XMLIn){
If ($line -match "$ShortDate") {
$line = [regex]::Replace($line, $ShortDate, $($Matches["Shortdate"]))
}
$line
#$Script:outfile += $line + "`n"
}
}

Function Remove-ScheduledTask {

}

Function New-ScheduledTask {

}

$schtask = Schtasks.exe /query /s "localhost" /V /FO CSV | ConvertFrom-Csv

if ($schtask) {

Foreach ($sch in $schtask) {

if ($Sch."Run As User" -like "$($domainname)*") {
$sch
}
}

$outfile = ""
Change-scheduledtask $(Get-Content c:\temp\TestTask.xml)
[/ps]

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">