![]() |
Remove-DtJob |
This cmdlet deletes the specified job from the specified server. A running job will be stopped before it is deleted. For this cmdlet, the -ServiceHost should be your target server.
Remove-DtJob [-JobId] <Guid> [-DeleteOptions] <DeleteOptions> [-ServiceHost] <Server> [<CommonParameters>]
Remove-DtJob [-JobInfo] <JobInfo> [-DeleteOptions] <DeleteOptions> [-ServiceHost] <Server> [<CommonParameters>]
Required? |
false |
Position? |
3 |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
Required? |
true |
Position? |
2 |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
Required? |
true |
Position? |
named |
Accept Pipeline Input? |
true (ByValue) |
Accept Wildcard Characters? |
false |
Required? |
true |
Position? |
1 |
Accept Pipeline Input? |
true (ByPropertyName) |
Accept Wildcard Characters? |
false |
This cmdlet supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, WarningVariable, OutBuffer, PipelineVariable, and OutVariable. For more information, see about_CommonParameters. |
A server object is created for the server beta using the domain\administrator and password credentials. It assigns the server object to the variable called DtServerObjectBeta. The job(s) are retrieved from DtServerObjectBeta, but only the job information where the source machine name is equivalent to the name stored in the variable DtServerObjectAlpha is retrieved. That information is then stored in the variable DtJobForAlpha. The delete options are stored in DtDeleteOptions, then the specific delete option DiscardTargetQueue is set to true. Finally the job is removed using the delete options. The connections for the server object are then closed.
$DtServerObjectBeta = New-DtServer -Name beta -UserName domain\administrator -Password password
$DtJobForAlpha = Get-DtJob -ServiceHost $DtServerObjectBeta | Where-Object {$_.Statistics.CoreConnectionDetails.SourceMachineName -eq $DtServerObjectAlpha}
$DtDeleteOptions = New-Object DoubleTake.Jobs.Contract.DeleteOptions
$DtDeleteOptions.DiscardTargetQueue = $true
Remove-DtJob -ServiceHost $DtServerObjectBeta -JobId $DtJobForAlpha.Id -DeleteOptions $DtDeleteOptions
Disconnect-DtServer -ServiceHost $DtServerObjectBeta