[Powershell]導出指定的定時計劃任務

<# .NOTES =========================================================================== Created with: Visual Studio 2019 Created on: 2019/8/23 18:00 Created by: Allen.Cai Organization: Allen.Cai Filename: export.ps1 =========================================================================== .DESCRIPTION ERP job scheduled tasks export scripts. #> $CurrentDate = Get-Date $LogFile = "D:\backup\Tasks\ExportScheduledTasks_$($CurrentDate.ToString("yyyyMMddHHmmss")).log" Start-Transcript -Path $LogFile $BackupPath = "D:\backup\Tasks" $ScheduledTaskPathRoot = "\Microsoft\ERP\" Write-Host "Start exporting of scheduled tasks." Get-ScheduledTask -TaskPath $ScheduledTaskPathRoot | ForEach-Object { $taskPath = $_.TaskPath $taskName = $_.TaskName New-Item -ItemType "directory" -Path "$BackupPath$taskPath" -ErrorAction SilentlyContinue $taskInfo = Export-ScheduledTask -TaskName $taskName -TaskPath $taskPath $taskInfo | Out-File "$BackupPath$taskPath$taskName.xml" } Write-Host "Saved file $BackupPath$TaskFolder$TaskName.xml" Stop-Transcript
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章