Pipe output to the clipboard using clip.exe

Quick one today, a very simple trick I learned a few days ago: if you need to copy and paste your output from the console, instead of using the markup tools built in to cmd.exe, you can simply pass your output directly to the clipboard.  No big trick needed for this; just pipe the output to clip.exe and it will be put on the clipboard, ready to be pasted wherever you need.  It's built in to the OS, so you don't need to download and install anything.

Let's say I have a list of user account I've grabbed from Active Directory and saved to the variable $users, and I need to send that list in an email.  I could enter "$users" by itself on the command line, then select and hit enter to copy.  Then I would paste the list...and find I need to strip out all of the white space this creates. It's not hard, but it can be inconvenient sometimes, especially if it's a long list.

Instead, I could just run "$users | clip.exe" and get the same effect, only without jumping through hoops, without the chance of over or under selecting, and without selecting a bunch of extra white space.

It's really that easy.  Just add " | clip.exe" to the end and it will throw the screen output into the clipboard directly instead of on to the screen, and then you can paste it normally.

Test execution speed with Measure-Command

When hacking away at a shell or writing a quick on-off script that will only do a handful of things and only once, knowing how fast each part works isn't that big of a deal.  When you're writing something that will get reused over and over, especially if it's something that's working against a large collection (such as, for example, running a WMI query against every computer in your domain), knowing how quickly different commands run could be quite important, especially if you're looking to improve execution speed.

To test execution speed, I use Measure-Command.

Read More

Better place to PowerShell (say goodbye to cmd.exe)

I'll be honest, I hate cmd.exe, which is what PowerShell uses by default.  It's functional, but crude, old fashioned and basic. I had been using ConEmu for some time, and it's an excellent product, but I ran into another that I feel fixes all of the problems with cmd (and even the last nagging issue I had with ConEmu): Cmder.  It uses ConEmu for the console emulator, it's completely portable, and when you just need a windows command prompt (rather than PowerShell), it gives you a Bash-like shell experience (unfortunately, trying to get the bash-like enhancements to work in PowerShell broke tab completion for PowerShell cmdlets for me, so I had to stick with PowerShell style tab completion).

Anyway, it's a great functioning, great looking console emulator, and I highly recommend giving it a try.