docs/_data/Help/Get-WhereFor.json

{
  "Synopsis": "WhereFor: Where-Object + Foreach-Object",
  "Description": "WhereFor is a small command that allows you to filter and process objects in a single pipeline.\n\nThis allows a single object pipeline to be split into multiple conditions and actions.\n\nWhereFor takes a list of dictionaries where each key is a condition and each value is an action.\n\nAny input object that matches a condition will run the action.\n\nThis will all happen within a\n[steppable pipeline](https://learn.microsoft.com/en-us/dotnet/api/system.management.automation.steppablepipeline?view=powershellsdk-7.4.0&wt.mc_id=MVP_321542),\nso you can use it in a pipeline.\n\nIt has a few aliases:\n\n* `?%`\n* `WhereFor`\n* `WhereFore`\n* `Get-WhereFore`",
  "Parameters": [
    {
      "Name": null,
      "Type": null,
      "Description": "",
      "Required": false,
      "Position": 0,
      "Aliases": null,
      "DefaultValue": null,
      "Globbing": false,
      "PipelineInput": null,
      "variableLength": false
    }
  ],
  "Notes": [
    null
  ],
  "CommandType": "Function",
  "Component": [
    null
  ],
  "Inputs": [
    null
  ],
  "Outputs": [
    null
  ],
  "Links": [],
  "Examples": [
    {
      "Title": "EXAMPLE 1",
      "Markdown": "",
      "Code": "1..3 | ?% @{\n {$_ % 2} = {\"$_ is odd\"}\n {-not ($_ %2)}={\"$_ is even\"}\n}"
    },
    {
      "Title": "EXAMPLE 2",
      "Markdown": "",
      "Code": "Get-Process | \n WhereFor @{\n { $_.Handles -gt 1kb } = { \"$($_.Name) [ $($_.Id) ] has $($_.handles) open handles \" }\n { $_.WorkingSet -gt 1gb } = { \"$($_.Name) [ $($_.Id) ] is using $($_.WorkingSet) of memory\" }\n }"
    },
    {
      "Title": "EXAMPLE 3",
      "Markdown": "",
      "Code": "\"the quick brown fox jumped over the lazy dog\" -split '\\s' | \n Get-WhereFor ([Ordered]@{\n { $_ } =\n { \"Word: $_\"; \"Length: $($_.Length)\" }\n { $_ -match '[aeiou]' } =\n { \"Vowels: $($_.ToCharArray() -match '[aeiou]')\" }\n { $_ -match '[^aeiou]' } =\n { \"Consonant: $($_.ToCharArray() -match '[^aeiou]')\" }\n })"
    }
  ]
}