set-psReadLineKeyHandler
allows to define key sequences (shortcuts) that invoke handler functions that change the text in the PowerShell buffer that is being edited. 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')) }