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

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!

Thanks.

July 4th, 2013 6:43am

Update:

I've managed to get the match command correct:

Paramater:

# 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

Free Windows Admin Tool Kit Click here and download it now
July 4th, 2013 7:16am

Update:

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

July 4th, 2013 9:58am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics