Skip to content

Import-DrsRule does not support specifying rule by type #24

@Nick-Andreev

Description

@Nick-Andreev

It would be nice to be able to specify the rule not only by name, but also by type, when importing DRS rules from a file.

The way it's implemented right now, if I say have a host group called "host2" and VM to host rule "host2" and I call Import-DrsRule with the following parameters:

Import-DrsRule -Cluster "my-cluster" -Path "drs-rule-export.json" -Name "host2"

Cmdlet will attempt to import both the group and the rule, which is not always what you want. This is the bit of code that checks the name:

## if -Name was specified, filter
if ($PSBoundParameters.ContainsKey("Name")) {$arrRuleObjects_filtered = $arrRuleObjects_filtered | Where-Object -FilterScript {$_.Name -like $Name}}

The following piece of code will need to be added to also check for type:

## if -Type was specified, filter
if ($PSBoundParameters.ContainsKey("Type")) {$arrRuleObjects_filtered = $arrRuleObjects_filtered | Where-Object -FilterScript {$_.Type -like $Type}}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions