What is the difference between variables $a
and $b
?
$a = (Get-Date).DayOfWeek
$b = Get-Date | Select-Object DayOfWeek
First of all, you lack parentheses to call GetType. What you see is the MethodInfo describing the GetType method on [DayOfWeek]. To actually call GetType, you should do:
$a.GetType();
$b.GetType();
You should see that $a
is a [DayOfWeek], and $b
is a custom object generated by the Select-Object cmdlet to capture only the DayOfWeek property of a data object. Hence, it's an object with a DayOfWeek property only:
C:\> $b.DayOfWeek -eq $a
True