February 2019
Intermediate to advanced
626 pages
15h 51m
English
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 using the following code:
$process = Get-Process -Id $PID $process.Name
PowerShell also allows us to access these properties by enclosing a command in parentheses:
(Get-Process -Id $PID).Name
Properties of an object are objects themselves. For example, the StartTime property of a process is a DateTime object. We may access the DayOfWeek property by using the following code:
$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 ...
Read now
Unlock full access