Quick PowerShell Tips

12 Jun

Paste

In Command Prompt or PowerShell windows you can paste by right-clicking. But not always… Why?
Right-click the top bar and select properties.
QPT Properties
Select the Options tab and make sure the edit option ‘QuickEdit Mode’ is selected. Now the right-click paste is working.
QPT Properties QuickEdit Mode
Besides the right-click paste you’re getting now, also the instant ‘Mark’ is available. By left-clicking you can select text, press Enter or right-click and the selected text has been copied to the clipboard.

This functionality isn’t new, but very neat!

History

A known function is the up arrow key: with this command you can traverse through the commandline buffer and select one of the previous commands.
Another option is the F7 key (Alt-F7 to clear the history). It shows a menu of previously run commands!
QPT F7

This command history comes from the console-hosting application, not from PowerShell.

PowerShell maintains it’s own history and can be seen bij executing the following command
Get-History | Select -ExpandProperty CommandLine

When using the Get-History command and F7 in a SharePoint 2013 Management Shell you’ll notice the difference:
Get-History shows loading sharepoint.ps1 while the console history isn’t aware this command has even been executed.

 

QPT Up Arrow key vs F7

Output history

A tip to store the previous run commands:

Get-History | Select –Expand CommandLine | Out-File savemycommands.ps1

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.