系统相关
首页 > 系统相关> > powershell-批量导出Job

powershell-批量导出Job

作者:互联网

$CurrentDate = Get-Date
$LogFile = "D:\Job\ExportScheduledTasks_$($CurrentDate.ToString("yyyyMMddHHmmss")).log"  #导出过程日志的保存路径
Start-Transcript -Path $LogFile
$BackupPath = "D:\Job\"          #导出文件的保存路径
$ScheduledTaskPathRoot = "\NONEDI\"  #job的路径  以'/'开始
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

标签:taskName,导出,BackupPath,powershell,Job,TaskName,TaskPath,taskPath
来源: https://www.cnblogs.com/JinweiChang/p/14699103.html