connect to multiple O365 tenants

This topic contains 2 replies, has 2 voices, and was last updated by  Jeremy-Smit 11 months ago.

  • Author
    Posts
  • #61777

    Jeremy-Smit
    Participant

    people,

    I have a script to get a xml list with all user with office 365 license.
    we have serveral customers with O365 environment that we manage.

    is there a way to change the script that it connects to multiple tenants and get the list from there.
    is there further also possible to build in de the Admin credentials with secure password?

  • #61961

    Don Jones
    Keymaster

    There's no way to build in the Administrator credential securely, no, because you'd be storing the password in clear text.

    And yes, it should in theory be possible to connect to multiple tenants at once, but each of those would be a unique and individual connection. You can't say, "run this command against these 12 tenants all at once," necessarily (although, depending on the command involved, you might be able to send the same command to all the connection in parallel).

  • #62077

    Jeremy-Smit
    Participant

    Okay,
    Then hear me out for my next idea, if it will work

    is it posiible to build a large scripts that holds serveral time the script with credentials

    Like

    {
    $username = "O365admin1"
    $password = cat C:\temp\password.txt| convertto-securestring
    $Office365credentials = new-object -typename System.Management.Automation.PSCredential `
             -argumentlist $username, $password
    
    c:\scripts\O365licenties.ps1
    }
    {
    $username = "O365admin2"
    $password = cat C:\temp\password.txt| convertto-securestring
    $Office365credentials = new-object -typename System.Management.Automation.PSCredential `
             -argumentlist $username, $password
    
    c:\scripts\O365licenties.ps1
     }
    

    like that last line runs the script to get the licenses but you fill it out multiple times?

You must be logged in to reply to this topic.