0

while using Copy-DbaAgentJob dbatools cmd, what would need to passed to the parameter Job

  • is it an array with the names of the jobs to be copied
  • is it an array of actual jobs from the cmd Get-DbaAgentJob
jarlh
  • 42,561
  • 8
  • 45
  • 63
Raghav
  • 125
  • 2
  • 10

1 Answers1

0

As per Get-Help Copy-DbaAgentJob:

Copy-DbaAgentJob
    [[-Source] <DbaInstanceParameter>]
    [[-SourceSqlCredential] <PSCredential>]
    [-Destination] <DbaInstanceParameter[]>
    [[-DestinationSqlCredential] <PSCredential>]
    [[-Job] <Object[]>]
    [[-ExcludeJob] <Object[]>]
    [-DisableOnSource]
    [-DisableOnDestination]
    [-Force]
    [[-InputObject] <Job[]>]
    [-EnableException]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

The -Job parameter is an array of objects, but more specifically Get-Help Copy-DbaAgentJob -Detailed says:

-Job [<System.Object[]>]
    The job(s) to process. This list is auto-populated from the server.
    If unspecified, all jobs will be processed.

One of the examples provided by Get-Help Copy-DbaAgentJob -Examples also show that you can provide a list of existing jobs from the source server, filtered or otherwise:

Get-DbaAgentJob -SqlInstance sqlserver2014a |
  Where-Object Category -eq "Report Server" |
  Copy-DbaAgentJob -Destination sqlserver2014b
AlwaysLearning
  • 7,915
  • 5
  • 27
  • 35