I am running validations based on details about the machine the script is running on. I currently have an API that will return 1 of the following
Name1
Name1, Name2
Name1, Name3
Name1, Name2, Name3
Name2, Name3
Name2
Name3
What would be the most efficient way to run a different set of validations (functions) based upon one of those 7 results?
EDIT: Here is some pseudo code to represent what I am trying to accomplish. I am hoping to make the switch and values in the where-object
of each switch cleaner
function returnRelevantBlankValues {
$instance = $args[0] #could be any 7 of the strings above
$inputFile = "C:\path\input.txt"
$fileResults = "C:\path\output.txt"
switch ($instance){
"name1" {
Get-Content $inputFile | where-object {
$_ -like "*name1*" -and $_ -notlike "*name2*" -and $_ -notlike "*name3"} > $fileResults
}
"name1, name2" {
Get-Content $inputFile | where-object {
$_ -like "*name1*" -and $_ -like "*name1*" -and $_ -notlike "*name3"} > $fileResults
}
}
}