Internal/Show-IsApprovedVerb.ps1
function Show-IsApprovedVerb { <# .Synopsis Show-IsApprovedVerb checks for approved verb .DESCRIPTION Show-IsApprovedVerb checks for approved verb .EXAMPLE Show-IsApprovedVerb Get-Something Show-IsApprovedVerb Get-Something -WhatIf #> [CmdletBinding(SupportsShouldProcess=$true)] param ( [Parameter( Mandatory=$true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [string]$func ) BEGIN{ Write-Verbose "Starting Show-IsApprovedVerb..." }#begin PROCESS{ if ($psCmdlet.ShouldProcess(<# on target --> #>"$func", <# What if: Performing operation --> #>"Checking the ``Get-Verb`` list of verbs against the function name.")) { if ((Get-Verb).Verb -contains "$func".split("-")[0]) { Write-Verbose "Using an approved verb! You're awesome!" } else { Write-Verbose "This is not an approved verb! Run: ``Get-Verb`` to see the list of approved verbs" } } }#process END{ Write-Verbose "Finished Show-IsApprovedVerb..." }#end } |