Skip to content

Instantly share code, notes, and snippets.

@1RedOne
Created July 24, 2020 14:04
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 1RedOne/157672c745ce903a1f9ac4a5b17606b0 to your computer and use it in GitHub Desktop.
Save 1RedOne/157672c745ce903a1f9ac4a5b17606b0 to your computer and use it in GitHub Desktop.
Get matching keys from a hash table
$hash = @{
showThisOne = 'showMe1';
showThisTwo = 'showMe2';
showThisThree = 'showMe3';
showThisFour = 'showMe4';
DontShowThis = 'hideme';
AlsoDontShowThis = 'hideme';
}
if ($hash.keys -like "showThis*") {
"some keys match, showing values"
$Hash.Keys | ? {$_ -like "showThis*"} | % { [pscustomobject]@{Key = $_; Value = $hash.$_} }
}
@1RedOne
Copy link
Author

1RedOne commented Jul 24, 2020

You're right Adam, this syntax ain't so simple!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment