Last active
March 14, 2019 22:48
-
-
Save IISResetMe/e7740b3885eb6296a26b5f7f82a17c9a to your computer and use it in GitHub Desktop.
Hijack a subset of non-existing commands in PowerShell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ExecutionContext.InvokeCommand.CommandNotFoundAction = { | |
param([string]$CommandName, [System.Management.Automation.CommandLookupEventArgs]$evtArgs) | |
if($CommandName -like '*glue*'){ | |
$evtArgs.CommandScriptBlock = { | |
Write-Host "Eating glue because of $CommandName ..." -ForegroundColor Green | |
}.GetNewClosure() | |
$evtArgs.StopSearch = $true | |
} | |
} | |
Get-GlueStuff |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment