Data Protection Manager 2012 SP1: AddNewStandAloneVM.ps1 to include only certain name schema RRS feed

  • Question

  • Hi

    I'm making use of the AddNewStandAloneVM.ps1 Microsoft made available. I need this script to add certain virtual machines to certain Protection Groups. Example: AAA-WIN01, should be added to PG-VPS-WIN

    So I need to be able to specify the name within the script (*WIN*) then the script should only add the datasources that matches this name. 

    So far, I've been using an exclusion list, but it's a hassle to include loads of exlusions. To let the script match it would mean a cleaner script.

    Here's the part I've changed from AddNewStandAloneVM.ps1:

    # 7. If object is a data source and of type Hyper-V and is currently not protected add to list of unprotected VMs
    $unprotectedDsList = @($DSlist | ? {$($_.Type.IsDatasource) -and ($($_.Type.Id) -match $guid)`
    -and ($($_.Name) -notlike "Backup Using Saved State\*NIX*")`
    -and ($($_.Name) -notlike "Backup Using Child Partition\*NIX*")`

    Above should basically exlude any servername with 'NIX' in the name.

    Some help would be appreciated!


    Thursday, July 4, 2013 10:39 AM

All replies

  • Update:

    I've managed to get the match command correct:


    # Data Source Name Schema
    $vmname = "<VMNAME or WILDCARD>"

    $unprotectedDsList = @($DSlist | ? {$($_.Type.IsDatasource) -and ($($_.Type.Id) -match $guid) -and ($($_.Name) -match $vmname) -and ! $($_.Protected)})

    Now just to get the correct wilcard format to match something like: ABC01-WIN01

    Thursday, July 4, 2013 11:13 AM
  • Update:

    I've managed to complete the query - it's working successfully.

    Thursday, July 4, 2013 1:54 PM