Search notes:

PowerShell cmdLet set-psReadLineKeyHandler

set-psReadLineKeyHandler allows to define key sequences (shortcuts) that invoke handler functions that change the text in the PowerShell buffer that is being edited.
In the following example, two shortcuts are defined, alt+d and alt+t which insert the current date and time in ISO 8601 format:
PS C:\> set-psReadLineKeyHandler 'alt+t' { [Microsoft.PowerShell.PSConsoleReadLine]::Insert( [DateTime]::Now.ToString('HH:mm:ss'  )) }
PS C:\> set-psReadLineKeyHandler 'alt+d' { [Microsoft.PowerShell.PSConsoleReadLine]::Insert( [DateTime]::Now.ToString('yyyy-MM-dd')) }

See also

Powershell command noun: psReadLineKeyHandler

Index