Quick tip: chaining powershell commands

Let’s say, for example, that you’re doing something that takes a freaking age. You need a long-running process and want to fire and forget, but for analysis purposes, want to know how long it took (without sitting there for hours watching and waiting for it to complete.)

The answer is chaining powershell commands together with get-date.

eg.,

get-date;somelongrunningpowershell.ps1;get-date

In this case, it’s the ; that chains commands together.

OK, that was actually a bad example, because if you’re running a script you’re in control of, then obviously you can do whatever you like and output the timestamps then:

write-output $(get-date)

So a better example would be when you’re running a PS CMDLET:

get-date;restore-SPSite -Identity http://iheartsharepoint -Path "\\sharepoint\gets\mybackup.bak";get-date

Handy!

Be the first to comment

Leave a Reply

Your email address will not be published.


*