首页 > 系统服务 > 详细

[Powershell]导出指定的定时计划任务

时间:2019-09-07 16:56:38      阅读:124      评论:0      收藏:0      [点我收藏+]
<#  
    .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

[Powershell]导出指定的定时计划任务

原文:https://www.cnblogs.com/VAllen/p/export-scheduled-tasks-of-powershell.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!