IT Questions and Answers :)

Wednesday, January 3, 2018

Which of the following is not an automatic variable in PowerShell?

Which of the following is not an automatic variable in PowerShell?

  • $Matches
  • $Last
  • $args
  • $Error 

Which of the following is not an automatic variable in PowerShell?

EXPLANATION

While there are automatic variables for the last cmdlet executed, the last argument used in that cmdlet, and the exit status (False if it threw an error; True if it didn't), there is no automatic variable that represents the last full command, or the last command's output.  $Last is not an automatic variable in the shell.
$Error is an array that's populated by all errors output in the current session (by default, up to 256 errors, although this can be changed by changing the value in $MaximumErrorCount).
$args is an array containing any command line arguments that were passed to a function or script; it's only usable from within that function or script.  Typically, this is not used as "param()" is a lot more powerful and typically easier to work with.
$Matches is an array containing the results of the last match with regular expressions against a string.  Note that it does not get populated if the match was performed against an array; in that case, -match just outputs the matching items directly to output.

Share:

0 comments:

Post a Comment

Popular Posts