February 2019
Intermediate to advanced
626 pages
15h 51m
English
Objects returned by Get-WmiObject have a GetRelated method that can be used to find associated instances.
The GetRelated method accepts arguments that can be used to filter the results. The first argument, relatedClass, is used to limit the instances returned to specific classes, as shown here:
Get-WmiObject Win32_LogonSession | ForEach-Object {
[PSCustomObject]@{
LogonName = $_.GetRelated('Win32_Account').Caption
SessionStarted = [System.Management.ManagementDateTimeConverter]::ToDateTime($_.StartTime)
}
}
Read now
Unlock full access