I’m looking at PowerShell in action book (Amazing book !) and trying this little snippet :
$error = $( $output = myScript ) 2>&1
So if i replace ‘MyScript’ with Dir for example it give me this error,
Cannot overwrite variable Error because it is read-only or constant. At line:1 char:1 + $error = $( $output = dir ) 2>&1 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : WriteError: (Error:String) [], SessionStateUnauthorizedAccessException + FullyQualifiedErrorId : VariableNotWritable
Why is it not working ?