如何导出集群定时任务

How to Export Clustered Scheduled Task

我尝试导出集群计划任务的 XML。

我搜索 Export-ScheduledTask 对非集群任务的功能。

当我执行 Get-ClusteredScheduledTask 时,也许有一种通过 CIM 的方法我明白了。

但是我不知道怎么查询这个

CimClass              : Root/Microsoft/Windows/TaskScheduler:MSFT_ClusteredScheduledTask
CimInstanceProperties : {ClusterName, CurrentOwner, Resource, TaskDefinition...}
CimSystemProperties   : Microsoft.Management.Infrastructure.CimSystemProperties

编辑 1:

获取会员

$task | Get-Member


   TypeName: Microsoft.Management.Infrastructure.CimInstance#Root/Microsoft/Windows/TaskScheduler/MSFT_ClusteredScheduledTask

Name                      MemberType     Definition                                                                                                                      
----                      ----------     ----------                                                                                                                      
Clone                     Method         System.Object ICloneable.Clone()                                                                                                
Dispose                   Method         void Dispose(), void IDisposable.Dispose()                                                                                      
Equals                    Method         bool Equals(System.Object obj)                                                                                                  
GetCimSessionComputerName Method         string GetCimSessionComputerName()                                                                                              
GetCimSessionInstanceId   Method         guid GetCimSessionInstanceId()                                                                                                  
GetHashCode               Method         int GetHashCode()                                                                                                               
GetObjectData             Method         void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context...
GetType                   Method         type GetType()                                                                                                                  
ToString                  Method         string ToString()                                                                                                               
ClusterName               Property       string ClusterName {get;}                                                                                                       
CurrentOwner              Property       string CurrentOwner {get;}                                                                                                      
PSComputerName            Property       string PSComputerName {get;}                                                                                                    
Resource                  Property       string Resource {get;}                                                                                                          
TaskDefinition            Property       CimInstance#Instance TaskDefinition {get;set;}                                                                                  
TaskName                  Property       string TaskName {get;}                                                                                                          
TaskType                  ScriptProperty System.Object TaskType {get=[Microsoft.PowerShell.Cmdletization.GeneratedTypes.ScheduledTask.ClusterTaskTypeEnum]($this.PSBas...

试试这个

$TaskName = "Change_NTFS_permissions"

Get-ChildItem -Path ($env:SystemRoot + 
                   '\System32\Tasks\Microsoft\Windows\Failover Clustering') 
                   -File -Recurse | ? {$_.Name -like $TaskName} | Get-Content | 
                   Out-File -FilePath ('C:\scripts\XML_Shedules' + '\' + $TaskName + '.xml')