Created
July 24, 2020 14:04
-
-
Save 1RedOne/157672c745ce903a1f9ac4a5b17606b0 to your computer and use it in GitHub Desktop.
Get matching keys from a hash table
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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.$_} } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You're right Adam, this syntax ain't so simple!