< Back

New-NsxDynamicCriteriaSpec

Sat Jan 18, 2020 9:14 pm

NAME New-NsxDynamicCriteriaSpec



SYNOPSIS

Creates a new Security Group Dynamic Membership Criteria Spec.





SYNTAX

New-NsxDynamicCriteriaSpec -Key <String> -Condition <String> -Value <String> [<CommonParameters>]



New-NsxDynamicCriteriaSpec -Entity <Object> [<CommonParameters>]





DESCRIPTION

NSX Security Groups can have 3 types of membership configured, Dynamic

Criteria, Static Members and Exclude Members.



One or more Dynamic Criteria combine to make a Dynamic Member Set, and one

or more Dynamic Member Sets combine to define the Dynamic Membership of a

given security group.



In order to allow the configuration of a security groups Dynamic Membership

with an aritrary number of Dynamic Criteria Member Sets that contain an

arbitrary number of Dynamic Criteria in a flexible way, PowerNSX provides

the following abstractions.



Creation of individual Dynamic Criteria is accomplished with

New-NsxDynamicCriteriaSpec.



One or more Dynamic Criteria can be added to a Dynamic Member Set at creation

time with Add-NsxDynamicMemberSet and specifying the required Dynamic

Criteria Spec objects at creation time.



One or more Dynamic Criteria can be added to an existing Dynamic Member Set

after the fact with Add-NsxDynamicCriteria or removed with

Remove-NsxDynamicCriteria.



One or more Dynamic Member sets can be added to a security groups overall

Dynamic Membership definition using Add-NsxDynamicMemberSet or removed using

Remove-NsxDynamicMemberSet



A Security Groups Dynamic Member definition can include multiple Dynamic

Member Sets in an logical AND/OR arrangement, and for each of the Dynamic

Member Sets, a match operator of ALL or ANY can be specified that determines

how multiple Dynamic Criteria within the set combine to define a match.



Dynamic Criteria consist of the following three elements:



The Key: This is the attribute that is to be evaluated. The list of Keys

available (along with their UI representation) are as follows:



Key UI Name

----------------------- --------

OSName Computer OS Name

ComputerName Computer Name

VmName VM Name

SecurityTag Security Tag



The condition: This is the criteria that will be used to evaluate the

provided value. The possible options for condition are as follows:



Condition UI Name

--------------- ---------------------------

contains Contains

ends_with Ends with

starts_with Starts with

equals Equals to

notequals Not Equals to

regex Matches regular expression



The Value: This is the string of text that is required to be matched

against the Key provided using the condition specified.



It is also possible to specify an object to use as part of a Dynamic

Criteria Spec. To do this, a valid PowerCLI or PowerNSX object must be

specified using the entity parameter. Using the entity parameter is the

equivalant of statically including the object within the Dynamic Criteria

Spec.



A valid PowerCLI session is required to pass certain types of objects

when specifying an entity.





PARAMETERS

-Key <String>

The attribute that is to be evaluated. The list of keys is described in the help description.



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Condition <String>

The condition used to evaluate the criteria value against the its key



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Value <String>

The value of the criteria to be evaluated.



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Entity <Object>

The Entity to be matched. This can be a Valie PowerNSX such as logical switch or PowerCLI object such as VM.



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



-------------------------- EXAMPLE 1 --------------------------



PS C:\\>$criteriaSpec11 = New-NsxDynamicCriteriaSpec -key VmName -condition contains



-value "VM"



Match all VMs where the VM name contains the string "VM"



VM Name Matched

--------------- -------

Test-VM-01 Yes

Test-VM-42 Yes

Test-VM-142 Yes

Prod-VM-01 Yes

Prod-PCI-VM-01 Yes

Test-VM-01-Template Yes

WIN-DC-01 No









-------------------------- EXAMPLE 2 --------------------------



PS C:\\>$criteriaSpec12 = New-NsxDynamicCriteriaSpec -key VmName -condition equals



-value "Test-VM-01"



Match all VMs where the VM name is equal to the string "Test-VM-01"



VM Name Matched

--------------- -------

Test-VM-01 Yes

Test-VM-42 No

Test-VM-142 No

Prod-VM-01 No

Prod-PCI-VM-01 No

Test-VM-01-Template No

WIN-DC-01 No









-------------------------- EXAMPLE 3 --------------------------



PS C:\\>$criteriaSpec13 = New-NsxDynamicCriteriaSpec -key VmName -condition



notequals -value "Test-VM-01"



Match all VMs where the VM name is NOT equal to the string "Test-VM-01"



VM Name Matched

--------------- -------

Test-VM-01 No

Test-VM-42 Yes

Test-VM-142 Yes

Prod-VM-01 Yes

Prod-PCI-VM-01 Yes

Test-VM-01-Template Yes

WIN-DC-01 Yes









-------------------------- EXAMPLE 4 --------------------------



PS C:\\>$criteriaSpec14 = New-NsxDynamicCriteriaSpec -key VmName -condition



starts_with -value "Test"



Match all VMs where the VM name starts with the string "Test".



VM Name Matched

--------------- -------

Test-VM-01 Yes

Test-VM-42 Yes

Test-VM-142 Yes

Prod-VM-01 No

Prod-PCI-VM-01 No

Test-VM-01-Template Yes

WIN-DC-01 No









-------------------------- EXAMPLE 5 --------------------------



PS C:\\>$criteriaSpec15 = New-NsxDynamicCriteriaSpec -key VmName -condition



ends_with -value "01"



Match all VMs where the VM name ends with the string "01".



VM Name Matched

--------------- -------

Test-VM-01 Yes

Test-VM-42 No

Test-VM-142 No

Prod-VM-01 Yes

Prod-PCI-VM-01 Yes

Test-VM-01-Template No

WIN-DC-01 Yes









-------------------------- EXAMPLE 6 --------------------------



PS C:\\>$criteriaSpec16 = New-NsxDynamicCriteriaSpec -key VmName -condition regex



-value "^Test-VM-[0-9]{2}$"



Match all VMs where the VM name matches the supplied regular expression.



VM Name Matched

--------------- -------

Test-VM-01 Yes

Test-VM-42 Yes

Test-VM-142 No

Prod-VM-01 No

Prod-PCI-VM-01 No

Test-VM-01-Template No

WIN-DC-01 No









-------------------------- EXAMPLE 7 --------------------------



PS C:\\>$criteriaSpec21 = New-NsxDynamicCriteriaSpec -entity (Get-NsxLogicalSwitch



DMZ-LS-1)



Statically specify the NSX Logical Switch called DMZ-LS-1 to be included as

part of the dynamic criteria









-------------------------- EXAMPLE 8 --------------------------



PS C:\\>$criteriaSpec22 = New-NsxDynamicCriteriaSpec -operator AND



-entity $(Get-NsxSecurityGroup SG-PCI-Machines)



Statically specify the NSX Security Group called SG-PCI-Machines to be

included as part of the dynamic criteria











RELATED LINKS