In the example below after Measure-Command variable x is updated, but in example with my own version of command x remains the same.
$x = 0
Measure-Command -Expression { $x++ } | Out-Null
$x # outputs 1
function Measure-Command2
{
param([ScriptBlock]$Expression)
. $Expression
}
$x = 0
Measure-Command2 -Expression { $x++ }
$x # outputs 0
Can I use the same magic in my own functions?