Public/Remove-PsFunction.ps1
|
function Remove-PsFunction { <# .Synopsis Removes a module's function and test files .DESCRIPTION Removes a module's function and test files .EXAMPLE Remove-PsFunction "AwesomeModule" "Write-Stufff" #> [CmdletBinding(SupportsShouldProcess=$true)] param ( [Parameter(Mandatory=$true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [string]$ModuleName, [Parameter(Mandatory=$true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [string]$FunctionName ) BEGIN{ . "$PSscriptRoot\Get-PsModuleBuilderPath.ps1" $path = Get-PsModuleBuilderPath $functionFiles = Get-ChildItem "$path\$ModuleName\*\$FunctionName*ps1" $whatifMessage = @" Removing: $($functionFiles | ForEach-Object { $_.FullName }) "@ }#begin PROCESS{ if ($psCmdlet.ShouldProcess("Removing $FunctionName from $ModuleName", $whatifMessage)) { Write-Debug $whatifMessage $functionFiles | Remove-Item -Force } }#process END{ }#end } |