-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".
    "Dear Lord... I'm a DBA so please give me patience because, if you give me strength, I'm going to need bail money too!"

    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'
    )

    Jack Corbett
    Consultant - Straight Path Solutions
    Check out these links on how to get faster and more accurate answers:
    Forum Etiquette: How to post data/code on a forum to get the best help
    Need an Answer? Actually, No ... You Need a Question

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

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