Properties of an object in PowerShell may be accessed by writing the property name after a period. For example, the Name property of the current PowerShell process may be accessed by the following:
$process = Get-Process -Id $PID $process.Name
PowerShell also allows us to access the properties by enclosing a command in parentheses:
(Get-Process -Id $PID).Name
Properties of an object are themselves objects. For example, the StartTime property of a process is a DateTime object. We may access DayOfWeek property by using the following:
$process = Get-Process -Id $PID $process.StartTime.DayOfWeek
The variable assignment step may be skipped if parentheses are used:
(Get-Process -Id $PID).StartTime.DayOfWeek
If a property name has a space, it may be accessed using a number of different notation styles. For example, a property named "Some Name" may be accessed by quoting the name or enclosing the name in curly braces:
$object = [PSCustomObject]@{ 'Some Name' = 'Value' } $object."Some Name" $object.'Some Name' $object.{Some Name}