Retrieving multl-layered expanded properties in a Powershell array

I’m making a PowerShell call that retrieves an array of objects within Microsoft.Graph.Identity.Governance. These objects have StartDateTime and EndDateTime values but they’re nested within a ScheduleInfo property, which requires multiple expansions to reach them. Can someone help me with syntax to retrieve these values, given the details below?

Background: Privileged Identity Management (PIM) for Groups in Microsoft Entra can be used to add/remove M365 group members in a time-based capacity for time-based workflows. (This is an offshoot of the original PIM for Azure-based Roles, and so there are some cool use cases possible here). There is an eligible layer and an active layer; we are only concerned with the active layer for our scope. When a member is actively assigned, this is tracked as a running history. PowerShell support for this feature set is evolving, and there are different modules in play and limited methods to pick and choose from.

Details:

We can store the Active assignment history for a known Microsoft.Graph user and group using Microsoft.Graph.Identity.Governance:

$Group = get-mggroup -Filter "DisplayName eq 'TEST-PIM-Group'"
$user = get-mguser -UserId [email protected]

$assigns=@(Get-MgIdentityGovernancePrivilegedAccessGroupAssignmentScheduleRequest `
-Filter "groupId eq '$($Group.Id)' and principalId eq '$($user.Id)' and accessId eq 'member'")

Output might look like this:

$assigns | select Action, CompletedDateTime, Justification, ScheduleInfo

Action      CompletedDateTime   Justification     ScheduleInfo
------      -----------------   -------------     ------------
adminAssign 5/1/2024 4:47:41 PM Assigned on 5/1   Microsoft.Graph.PowerShell.Models.MicrosoftGraphRequestSchedule
adminAssign 5/6/2024 1:14:33 PM Reassigned on 5/6 Microsoft.Graph.PowerShell.Models.MicrosoftGraphRequestSchedule

Now the fun: To retrieve StartDateTime for the first entry we can expand the ScheduleInfo property:

$assigns[0] | select -ExpandProperty ScheduleInfo | fl

Expiration           : Microsoft.Graph.PowerShell.Models.MicrosoftGraphExpirationPattern
Recurrence           : Microsoft.Graph.PowerShell.Models.MicrosoftGraphPatternedRecurrence
StartDateTime        : 5/1/2024 4:47:41 PM
AdditionalProperties : {}

…but to retrieve the EndDateTime, we need to expand the nested Expiration:

$assigns[0] | select -ExpandProperty ScheduleInfo | select -ExpandProperty Expiration

EndDateTime          Type
-----------          ----
5/5/2024 10:00:00 PM afterDateTime

Final ask:

I know the last two custom expressions aren’t correct, but everything else here would work: Is there any way to retrieve the StartDateTime and EndDateTime along these lines?

$assigns | 
ForEach-Object {
  [pscustomobject]@{
      Group             = $group.DisplayName
      User              = $user.UserPrincipalName
      Action            = $_.Action
      CompletedDateTime = $_.CompletedDateTime
      Justification     = $_.Justification
      StartDateTime     = @{Name='StartDateTime';Expression={ select -expandProperty $_.ScheduleInfo | select StartDateTime }}
      EndDateTime       = @{Name='EndDateTime';Expression={ select -expandProperty $_.ScheduleInfo | select StartDateTime | select -ExpandProperty Expiration | select EndDateTime }}
    }
}

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật