Public/Stop-Psm.ps1

function Stop-Psm {
  <#
    .Synopsis
      Stop-Psm removes all of the public and internal functions from the current session
    .DESCRIPTION
      Stop-Psm removes all of the public and internal functions from the current session
    .EXAMPLE
      Stop-Psm
  #>
      
  [CmdletBinding(SupportsShouldProcess=$true)]  
  param (
  )  

  BEGIN{
    Write-Verbose "Starting Stop-Psm..."
    Confirm-IsInitializedModulePath
    $psd1 = Import-Clixml .\module-psd1.xml
    $folderPath = "Module-Stop"
  }#begin

  PROCESS{
    if ($psCmdlet.ShouldProcess(<# on target --> #>"Module Name", <# What if: Performing operation --> #>"Removing all public and internal functions from the PS session")) { 
      If (Test-Path -Path $folderPath -PathType Container) {

        Write-Verbose -Message "Importing from $folder"
        $scripts = Get-ChildItem -Path $folderPath -Filter "*.ps1" 
        
        ForEach ($script in $scripts) {

          Write-Verbose -Message " Importing $($script.BaseName)"
          . $($script.FullName) -Verbose
          
        }
      } else {
        Write-Error "Please pass a script block as a string to 'Stop-Psm' or create scripts in the $folderPath/ directory"
      }
    }
  }#process
  END{
    Write-Verbose "Finished Stop-Psm..."
  }#end
}