How can I produce the Result.CSV file after comparing the two variable contents below?
$LicensedUsers.UserPrincipalName against $AuditLogsUser
Get the users:
$LicensedUsers = Get-MgUser | Sort-Object UserPrincipalName
Get the User account (UPN) from the audit logs:
$AuditLogsUser = Import-Csv -Path 'C:\Logs.csv' | Select-Object -ExpandProperty UserID -Unique | Sort-Object
Result.CSV file:
DisplayName, Mail, UserPrincipalName, Status
John Matrix, John.Matrix@domain.com, John.Matrix@domain.local, Active
user name, user.name@domain.com, user.name@domain.local, Inactive
old. User, old.user@domain.com, old.user@domain.local, Inactive