How to have properties with multiple expressions export to csv in multiple columns RRS feed

  • Question

  • I am not sure if I worded that right. I created a script to query AAD to track which user's in our enviroment have MFA setup. The problem is that some of the properties have multiple objects in them, so all of some of the properties will end up in the same csv column.

    Hers is the script so far minus the connection commands:

    $users = Get-msoluser -All 
    $users | select DisplayName,@{N='Email';E={$_.UserPrincipalName}},@{N='StrongAuthenticationRequirements';E={($_.StrongAuthenticationRequirements.State)}},@{N='StrongAuthenticationMethods';E={($_.StrongAuthenticationMethods.MethodType)}},@{N='IsDefault';E={($_.StrongAuthenticationMethods.IsDefault)}} | Export-Csv -NoTypeInformation C:\MFA_Status.csv

    Example of the output:

    Email                             StrongAuthenticationRequirements     Enforced

    StrongAuthenticationMethods                     IsDefault

    PhoneAppMotification TwoWayVoiceMobile   True False

    How can I script this so that properties that return more than one object a placed in a separate column, so ISDefault True is in it's own column and IsDefault False is in it's own?

    • Edited by Hero's Bane Wednesday, July 25, 2018 12:33 PM
    • Moved by Bill_Stewart Tuesday, December 11, 2018 9:19 PM This is not "scripts on demand"
    Wednesday, July 25, 2018 12:32 PM

All replies