private/CommandNotFound.ps1
function CommandNotFound($actions, $isUnderTest) { $ExecutionContext.SessionState.InvokeCommand.CommandNotFoundAction = { param($CommandName, $CommandLookupEventArgs) if ($CommandName -like 'get-*') { return } if (!(&$isUnderTest) -and $CommandLookupEventArgs.CommandOrigin -ne 'Runspace') { return } $actions | % { &$_ $CommandName $CommandLookupEventArgs } }.GetNewClosure() } |