mercredi 1 février 2017

How can you compare a variable to an array in PowerShell?

I am attempting to create an audit of mailbox permissions in powershell and would like to remove specific accounts from the output within the powershell script rather than manually afterwards.

In order to do this I am looking for a way to compare the contents of an array against a single string in powershell.

For example, if I was to declare an array:

$array = "1", "2", "3", "4"

I then want to find a way to do something like the below:

$a = "1"
$b = "5"

if ($a -ne *any string in $array*) {do something} #This should return false and take no action

if ($b -ne *any string in $array*) {do something} #This should return true and take action

I am at a loss for how this would be accomplished, any help is appreciated

Aucun commentaire:

Enregistrer un commentaire