Friday, 4 January 2013

What's the Powershell equivalent of back tick on bash?

I was wondering this myself today and it's one of them questions, where you say, well of course.

In Powershell, one uses $( ) to evaluate sub-expressions, so say that you wanted to pass your username to a PowerShell script.

You could do this:
$user = whoami
myscript.ps1 $user
But this is more elegant
myscript.ps1 $(whoami)
From here.

No comments:

Post a Comment