-ExcludeJob with list dbatools

  • Hello everyone ,

    I would like to transfer job sql lists through dbatools through the Copy-DbaAgentJob command

    only I want to exclude a list of jobs

    the lists is a long

    thank you for your help

    $Source        = 'production\REF '
    $Destination = 'localhost'
    $SharedPath = '\\production\migration'

    Copy-DbaDatabase -Source $Source -Destination $Destination -Database exploit -BackupRestore -SharedPath $SharedPath -force

    Copy-DbaLinkedServer -Source FRSADV005\COMPTOIR -Destination localhost -Force

    Copy-DbaLogin -Source FRSADV005\COMPTOIR -Destination localhost -Force

    Copy-DbaDbMail -Source FRSADV005\COMPTOIR -Destination localhost

    Copy-DbaAgentOperator -Source FRSADV005\COMPTOIR -Destination localhost

    Copy-DbaAgentAlert -Source FRSADV005\COMPTOIR -Destination localhost

    Copy-DbaAgentJob -Source FRSADV005\COMPTOIR -Destination localhost -ExcludeJob 'ExtranetDossierEntite_Delete' , 'ExtranetDossierEntite_Delete' ,
    'update_stats' , 'transfert_job_sql' , 'alerte_test_operation', 'test_transfert_operation '
  • Thanks for posting your issue and hopefully someone will answer soon.

    This is an automated bump to increase visibility of your question.

  • What's the problem? Does Copy-DbaAgentJob error out on your list?

  • I would like to put all jobs in a list and make a call to a single variable

    $Source        = 'frsadv007\referentiel'
    $Destination = 'localhost'
    $SharedPath = '\\FRSADV005\migration'

    $job = @{
    'BASELINE_CaptureConfigData',
    'ExtranetDossierEntite_Delete'
    'update_stats' ,
    'transfert_job_sql' ,
    'alerte_test_operation'
    'test_transfert_operation'
    }


    Copy-DbaDatabase -Source $Source -Destination $Destination -Database exploit -BackupRestore -SharedPath $SharedPath -force

    Copy-DbaLinkedServer -Source FRSADV005\COMPTOIR -Destination localhost -Force

    Copy-DbaLogin -Source FRSADV005\COMPTOIR -Destination localhost -Force

    Copy-DbaDbMail -Source FRSADV005\COMPTOIR -Destination localhost

    Copy-DbaAgentOperator -Source FRSADV005\COMPTOIR -Destination localhost

    Copy-DbaAgentAlert -Source FRSADV005\COMPTOIR -Destination localhost

    Copy-DbaAgentJob -Source FRSADV005\COMPTOIR -Destination localhost -ExcludeJob $job

    Sans titre3

    Attachments:
    You must be logged in to view attached files.
  • write to the people that created DBATools and ask them. 😉

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • You are not defining the array of jobs properly.   You need to replace the curly braces with parenthesis.

    $job = @(
    'BASELINE_CaptureConfigData',
    'ExtranetDossierEntite_Delete'
    'update_stats' ,
    'transfert_job_sql' ,
    'alerte_test_operation'
    'test_transfert_operation'
    )

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply