locked
Error Handling and Export to CSV RRS feed

  • General discussion

  • Hi, 

    I have a list of 1500 users and exporting their recipient type to CSV. While doing this i am coming across users who are no more in our system. I want to export that info as well in my CSV. Now I want to write this error value into cvs file like "user not available" in a separate column of csv file so that  have a combined list of users who are available and are not available in exchange online.How can I do that using exchange online power shell. My Original script is:

    import-csv 'C:\Users\admin\Desktop\getallusers.csv' | foreach {Get-Mailbox $_.email | select primarysmtpaddress, displayname } | Export-Csv 'C:\Users\admin\Desktop\getallusersResults.csv' -NoTypeInformation

    How can i modify this to add column of user status which tells if user is not found. 


    Hasan

    • Changed type Bill_Stewart Monday, March 12, 2018 9:04 PM
    • Moved by Bill_Stewart Monday, March 12, 2018 9:05 PM This is not "teach me PowerShell step-by-step in a forum" forum
    Monday, January 29, 2018 4:00 PM

All replies

  • If Get-Mailbox returns nothing, then output an object with primarysmtpaddress and displayname and put "not found" as one of the values.

    -- Bill Stewart [Bill_Stewart]

    Monday, January 29, 2018 4:03 PM
  • If Get-Mailbox returns nothing, then output an object with primarysmtpaddress and displayname and put "not found" as one of the values.

    -- Bill Stewart [Bill_Stewart]

    Can you refer a link to learn this? 

    Hasan

    Monday, January 29, 2018 7:07 PM
  • Learn link at the top of this page:

    https://technet.microsoft.com/en-us/scriptcenter/dd742419.aspx


    -- Bill Stewart [Bill_Stewart]

    Monday, January 29, 2018 7:26 PM
  • This video series on MVA is also very good.

    Learn PowerShell  


    \_(ツ)_/

    Monday, January 29, 2018 7:37 PM