PoshCode Archive  Artifact Content

Artifact 3a57328077c78c70cbaf347a9c82e9450af53bbe1010e5d36fffc4ee5cc1a44f:

  • File Select-TextOutput.ps1 — part of check-in [8526abbace] at 2018-06-10 13:07:17 on branch trunk — From Windows PowerShell Cookbook (O’Reilly) by Lee Holmes (user: Lee Holmes size: 941)

# encoding: ascii
# api: powershell
# title: Select-TextOutput.ps1
# description: From Windows PowerShell Cookbook (O’Reilly) by Lee Holmes
# version: 0.1
# author: Lee Holmes
# license: CC0
# x-poshcode-id: 2215
# x-archived: 2016-03-18T22:01:07
# x-published: 2011-09-09T21:42:00
#
#
##############################################################################
##
## Select-TextOutput
##
## From Windows PowerShell Cookbook (O'Reilly)
## by Lee Holmes (http://www.leeholmes.com/guide)
##
##############################################################################

<#

.SYNOPSIS

Searches the textual output of a command for a pattern.

.EXAMPLE

Get-Service | Select-TextOutput audio
Finds all references to "Audio" in the output of Get-Service

#>

param(
    ## The pattern to search for
    $Pattern
)

Set-StrictMode -Version Latest
$input | Out-String -Stream | Select-String $pattern