GetType used in PowerShell, difference between variables

后端 未结 3 366
离开以前
离开以前 2021-01-30 19:22

What is the difference between variables $a and $b?

$a = (Get-Date).DayOfWeek
$b = Get-Date | Select-Object DayOfWeek

3条回答
  •  猫巷女王i
    2021-01-30 19:56

    Select-Object creates a new psobject and copies the properties you requested to it. You can verify this with GetType():

    PS > $a.GetType().fullname
    System.DayOfWeek
    
    PS > $b.GetType().fullname
    System.Management.Automation.PSCustomObject
    

提交回复
热议问题