Powershell: Reference a property that contains a space Powershell: Reference a property that contains a space powershell powershell

Powershell: Reference a property that contains a space


Properties with embedded spaces have to be quoted when they're referenced:

 $case."Remaining Time - Hours"


Just to add, the property name can itself be a variable e.g.:

PS> $o = new-object psobject -prop @{'first name' = 'John'; 'last name' = 'Doe'}PS> $olast name                                         first name---------                                         ----------Doe                                               JohnPS> $prop = 'first name'PS> $o.$propJohn


Or you can also wrap that property in { }. Like this:

 $case.{Remaining Time - Hours}