Copy the PowerShell History to the Clipboard – Engineerer
309
post-template-default,single,single-post,postid-309,single-format-standard,wp-custom-logo,bridge-core-3.1.2,qode-page-transition-enabled,ajax_fade,page_not_loaded,,footer_responsive_adv,hide_top_bar_on_mobile_header,qode-content-sidebar-responsive,qode-theme-ver-30.1,qode-theme-bridge,qode_header_in_grid,elementor-default,elementor-template-full-width,elementor-kit-641,elementor-page-1064
Script

Copy the PowerShell History to the Clipboard

The first command, works. The second command does not. I try out and at some point reach my destination (e.g. I was able to create a File Share in an Azure Storage Account through the AZ CLI to move files from my client to an Azure VM).

Because I’m a good engineer I tend to save the commands to a reusable script – or I want to blog about it.

The following command will get all the commands you used before it copies those nuggets to the clipboard. From there, you can paste it in VS Code or, if you want to stay plain, in a notepad. Erase the lines you don’t need anymore (where you were not concentrated😉) and there you have your script. Clean it up, add some variables, make it shiny et voilà.

Get-History | select commandline | clip