Functions/sed.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
Filter sed { <# .SYNOPSIS A simple text filter to replace strings .DESCRIPTION A simple text filter to replace strings .PARAMETER Before The string searching for .PARAMETER After The string to replace it with .EXAMPLE 'Hello There' | sed 'Hello' 'Goodbye' Would return Goodbye There .OUTPUTS [string] #> #region Parameter [CmdletBinding(ConfirmImpact = 'None')] [OutputType('string')] [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', '')] Param( [Parameter(Mandatory, HelpMessage = 'Enter a string to search for', Position = 0, ValueFromPipeline = $False)] [string] $Before, [Parameter(Mandatory, HelpMessage = 'Enter a string to replace it with', Position = 1, ValueFromPipeline = $False)] [string] $After ) #endregion Parameter begin { Write-Verbose -Message "Starting [$($MyInvocation.Mycommand)]" } process { ForEach-Object { $_ -replace $before, $after } } end { Write-Verbose -Message "Ending [$($MyInvocation.Mycommand)]" } } |