Skip to content

Instantly share code, notes, and snippets.

@AspenForester
Last active June 11, 2018 13:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AspenForester/f47dce9af69ab88462de88af81a9285d to your computer and use it in GitHub Desktop.
Save AspenForester/f47dce9af69ab88462de88af81a9285d to your computer and use it in GitHub Desktop.
Compare one thing to a collection of wildcarded things
function Compare-Things
{
[CmdletBinding()]
[OutputType([bool])]
Param
(
# The singular thing that want to see if it matches
[Parameter(Mandatory=$true,
ValueFromPipelineByPropertyName=$true,
Position=0)]
[String]
$ThingA,
# Any of these things
[String[]]
$Things
)
Process
{
foreach ($thing in $Things)
{
if ($ThingA -like $thing)
{
return $true
}
}
return $false
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment