Since at least Powershell 5.1 you can use Compare-Object for comparing two arrays of values. A simplified example
$ProcessingModes = 'Service', 'Role', 'RoleService', 'Feature', 'Group', 'File', 'Package'
$ModesToCompare = 'Role', 'RoleService', 'Feature'
$Comparison = Compare-Object -ReferenceObject $ProcessingModes -DifferenceObject $ModesToCompare -IncludeEquals
$Comparison will give you the following output:
InputObject SideIndicator
----------- -------------
Role ==
RoleService ==
Feature ==
Service <=
Group <=
File <=
Package <=
This means that Service, Group, File, and Package only existed in the -ReferenceObject. By adding the -IncludeEquals you get exactly what you're looking for. You can now take this output and check if SideIndicator contains ==, like so:
if($Comparison.SideIndicator -contains "=="}
#some code here
}
$ProcessingModescontain multiple values (e.g. array) or just a single value?