Adicionar dados de teste ao seu locatário de teste do Office 365Add test data to your Office 365 test tenant

Configure sua assinatura do programa de desenvolvedor do O365 (ou outro locatário de teste) para facilitar o teste dos aplicativos que você criou.Set up your O365 developer program subscription (or other test tenant) to make it easy for you to test the apps that you've built. Ele ajudará você a:It will help you:

  • Criar novas equipes e canais em sua organizaçãoCreate new teams and channels in your organization

  • Adicione os usuários criados por meio do pacote de conteúdo do usuário a essas equipes.Add the users that are created via the User content pack to those teams.

Antes de começarBefore you start

Se você ainda não tem um locatário de teste, será necessário participar do programa de desenvolvedor do Office 365 e inscrever-se para uma assinatura de desenvolvedor.If you don't already have a test tenant, you will need to join the Office 365 developer program and sign up for a developer subscription. Você também precisará instalar os módulos do PowerShell necessários.You'll also need to install the necessary PowerShell modules. Para qualquer locatário que você usar, precisará ter permissões de administrador global para executar os scripts.For whatever tenant you use you'll need to have global administrator permissions to run the scripts.

  1. Ingressar no Programa para Desenvolvedores do Office 365Join the Office 365 Developer Program
  2. Configurar uma assinatura de desenvolvedor do Microsoft 365Set up a Microsoft 365 Developer Subscription
  3. Usar pacotes de dados de exemplo com sua assinatura de desenvolvedor do Office 365 para instalar o pacote de conteúdo de usuáriosUse sample data packs with your Office 365 developer subscription to install the Users content pack
  4. Instalar o módulo do teams PowerShellInstall the Teams PowerShell module
  5. Instalar o módulo PowerShell do Azure ADInstall the Azure AD PowerShell module

Etapa opcional: permitir o carregamento de aplicativos personalizadosOptional step: allow upload of custom apps

Por padrão, somente administradores globais ou administradores de serviços do teams podem carregar aplicativos personalizados no catálogo de aplicativos do locatário.By default, only global admins or teams service admins can upload custom apps into the tenant app catalog. Você também pode permitir que todos os usuários carreguem aplicativos personalizados para uso próprio ou para o Microsoft Teams para testes.You can also enable all users to upload custom apps for their own use or to teams for testing.

Para habilitar essa configuração, você precisará atualizar a política de instalação do aplicativo global no portal de administração do Microsoft Teams.To enable this setting, you'll need to update the global App Setup Policy in your Teams Admin Portal.

Para obter mais informações, consulte:For more information see:

Criar equipes e canaisCreate teams and channels

Salve o seguinte trecho de código como XML (. xml) e anote onde você o salvou.Save the following snippet as an XML (.xml) and note where you've saved it. Este XML define a estrutura das equipes e canais que serão criados-junto com seus membros.This XML defines the structure of the teams and channels that will be created - along with its members.

<?xml version="1.0"?>
<Teams>
  <Team Name="Store Portal" ID="storeportal" Description="" Type="Private" Creator="admin">
    <Members>
      <Member UserName="AlexW" IsOwner="false"/>
      <Member UserName="PattiF" IsOwner="false"/>
      <Member UserName="PradeepG" IsOwner="false"/>
      <Member UserName="JoniS" IsOwner="false"/>
      <Member UserName="JohannaL" IsOwner="false"/>
      <Member UserName="NestorW" IsOwner="false"/>
      <Member UserName="IsaiahL" IsOwner="false"/>
      <Member UserName="AdeleV" IsOwner="false"/>
      <Member UserName="LeeG" IsOwner="false"/>
      <Member UserName="MeganB" IsOwner="true"/>
      <Member UserName="LynneR" IsOwner="false"/>
      <Member UserName="GradyA" IsOwner="false"/>
      <Member UserName="LidiaH" IsOwner="false"/>
      <Member UserName="DiegoS" IsOwner="false"/>
      <Member UserName="MiriamG" IsOwner="true"/>
    </Members>
    <Channels>
      <Channel Name="Sales" ID="sales" Description="" Creator="Admin" />
      <Channel Name="Inventory" ID="inventory" Description="" Creator="Admin" />
      <Channel Name="Los Angeles Store 239" ID="losangelesstore239" Description="" Creator="Admin" />
      <Channel Name="Seattle Store 121" ID="seattlestore121" Description="" Creator="Admin" />
      <Channel Name="Online" ID="online" Description="" Creator="Admin" />
      <Channel Name="Store Layout" ID="storelayout" Description="" Creator="Admin" />
      <Channel Name="Promotions" ID="promotions" Description="" Creator="Admin" />
    </Channels>
  </Team>
  <Team Name="Mark 8 Project Team" ID="Mark8ProjectTeam" Description="Welcome to the team that we've assembled to create the Mark 8." Type="Private" Creator="admin">
    <Members>
      <Member UserName="meganb" IsOwner="true" />
      <Member UserName="alexw" IsOwner="false" />
      <Member UserName="lynner" IsOwner="false" />
      <Member UserName="isaiahl" IsOwner="false" />
      <Member UserName="leeg" IsOwner="false" />
      <Member UserName="pradeepg" IsOwner="false" />
      <Member UserName="lidiah" IsOwner="false" />
      <Member UserName="diegos" IsOwner="false" />
      <Member UserName="johannal" IsOwner="false" />
      <Member UserName="miriamg" IsOwner="false" />
      <Member UserName="adelev" IsOwner="false" />
      <Member UserName="jonis" IsOwner="false" />
      <Member UserName="nestorw" IsOwner="false" />
      <Member UserName="gradya" IsOwner="false" />
      <Member UserName="pattif" IsOwner="false" />
    </Members>
    <Channels>
      <Channel Name="Research and Development" ID="researchanddevelopment" Description="Channel for Research and Development!" Creator="meganb" />
      <Channel Name="Design" ID="design" Description="Discuss design projects." Creator="meganb" />
      <Channel Name="Digital Assets Web" ID="digitalassetsweb" Description="Discuss digital assets." Creator="meganb" />
      <Channel Name="Go to Market Plan" ID="gotomarketplan" Description="Our go-to-market plan!" Creator="meganb" />
    </Channels>
  </Team>
  <Team Name="District 9 Road Safety Audit" ID="district9roadsafetyaudit" Description="" Type="Private" Creator="admin">
    <Members>
      <Member UserName="meganb" IsOwner="true" />
      <Member UserName="alexw" IsOwner="false" />
      <Member UserName="lynner" IsOwner="false" />
      <Member UserName="isaiahl" IsOwner="false" />
      <Member UserName="leeg" IsOwner="false" />
      <Member UserName="pradeepg" IsOwner="false" />
      <Member UserName="lidiah" IsOwner="false" />
      <Member UserName="diegos" IsOwner="false" />
      <Member UserName="johannal" IsOwner="false" />
      <Member UserName="miriamg" IsOwner="false" />
      <Member UserName="adelev" IsOwner="false" />
      <Member UserName="jonis" IsOwner="false" />
      <Member UserName="nestorw" IsOwner="false" />
      <Member UserName="gradya" IsOwner="false" />
      <Member UserName="pattif" IsOwner="false" />
    </Members>
    <Channels>
      <Channel Name="Audit Planning" ID="auditplanning" Description="" Creator="Admin" />
      <Channel Name="Delivery" ID="delivery" Description="" Creator="Admin" />
      <Channel Name="Findings" ID="findings" Description="" Creator="Admin" />
      <Channel Name="Recommended Actions" ID="recommendedactions" Description="" Creator="Admin" />
      <Channel Name="Survey" ID="survey" Description="" Creator="Admin" />
    </Channels>
  </Team>
  <Team Name="ACC-1000 Product Team" ID="acc1000productteam" Description="" Type="Private" Creator="admin" >
    <Members>
      <Member UserName="meganb" IsOwner="true" />
      <Member UserName="alexw" IsOwner="false" />
      <Member UserName="lynner" IsOwner="false" />
      <Member UserName="isaiahl" IsOwner="false" />
      <Member UserName="leeg" IsOwner="false" />
      <Member UserName="pradeepg" IsOwner="false" />
      <Member UserName="lidiah" IsOwner="false" />
      <Member UserName="diegos" IsOwner="false" />
      <Member UserName="johannal" IsOwner="false" />
      <Member UserName="miriamg" IsOwner="false" />
      <Member UserName="adelev" IsOwner="false" />
      <Member UserName="jonis" IsOwner="false" />
      <Member UserName="nestorw" IsOwner="false" />
      <Member UserName="gradya" IsOwner="false" />
      <Member UserName="pattif" IsOwner="false" />
    </Members>
    <Channels>
      <Channel Name="Corporate Communication" ID="corporatecommunication" Description="" Creator="Admin" />
      <Channel Name="Lean Process Improvement" ID="corporatecommunication" Description="" Creator="Admin" />
      <Channel Name="Training and Certification" ID="trainingandcertification" Description="" Creator="Admin" />
      <Channel Name="Production" ID="production" Description="" Creator="Admin" />
      <Channel Name="Research and Development" ID="researchanddevelopment" Description="" Creator="Admin" />
      <Channel Name="Supplier Collaboration" ID="suppliercollaboration" Description="" Creator="Admin" />
    </Channels>
  </Team>
</Teams>

Salve o trecho de código a seguir como um script do PowerShell (. ps1) e anote onde você o salvou.Save the following snippet as a PowerShell script (.ps1) and note where you've saved it. Este script executa as etapas para criar equipes e canais e adicionar membros a eles.This script executes the steps to create the teams and channels and add members to them.

Param(
    [Parameter(Mandatory = $true)]
    
    # This specifies the location of your configuration XML.
    
    [string] $teamsFilePath 
)
    
[xml]$XmlDocument = Get-Content -Path $teamsFilePath.ToString()

if ($XmlDocument.Teams.Team.Count -gt 0) {

    try {
        
        # 1. Login with the global administrator account for your O365 Developer Program tenant.  This script will then use these credentials to connect to the powershell modules for Azure Active Directory and Microsoft Teams
        
        $creds = Get-Credential

        # Connecting to AAD PowerShell
        Connect-AzureAD -Credential $creds | Out-Null

        # Connect to Microsoft Teams PowerShell
        Connect-MicrosoftTeams -Credential $creds | Out-Null

        Write-Host "Connected to Microsoft 365 and configuring your organization with test teams and channels"

        # 2. Create the teams as specified in the XML.
        
        foreach ($team in $XmlDocument.Teams.Team ) {
            try {
                $group = New-Team -DisplayName $team.Name -Description $teams.description -visibility public 
                Write-Host "Successfully created team: " $group.DisplayName
            }
            catch {
                Write-Host "Unable to create team: $_"
            }
                
            # 3. Add users to the newly created teams.
            foreach ($user in $team.Members.Member) {
                try {
                    $newUserPrincipalName = (Get-AzureADUser -SearchString $user.UserName).UserPrincipalName

                    if($user.IsOwner -eq $true){
                        Add-TeamUser -GroupId $group.GroupId -User $newUserPrincipalName -Role Owner | Out-Null
                    }else{
                        Add-TeamUser -GroupId $group.GroupId -User $newUserPrincipalName | Out-Null
                    }

                    Write-Host "Successfully added user : " $user.UserName
                }
                catch {
                    Write-Host "Unable to add team user: $_"
                }

            }

            # 4. Add a set of channels to each newly created team
            foreach ($channel in $team.Channels.Channel) {
                try {
                    # Adding each team channel
                    New-TeamChannel -GroupId $group.GroupId -DisplayName $channel.Name -Description $channel.Description | Out-Null
                    Write-Host "Successfully created channel: " $channel.Name
                }
                catch {
                    Write-Host "Unable to add new Team Channel: $_"
                }   
            }

            Clear-Variable -Name group
        }

        Clear-Variable -Name creds
        
        # 5. Disconnect from all PowerShell sessions
        
        Write-Host "Completed execution and disconnecting from Microsoft 365 PowerShell sessions."
        Disconnect-MicrosoftTeams
        Disconnect-AzureAD
    }
    catch {
        Write-Host "Unable to complete the operation: $_"
    }
}
else {
    Write-Host "Content file has invalid data."
}

Abra uma sessão do Windows PowerShell no modo do administrador.Open a Windows PowerShell session in Administrator mode. Execute o script que você acabou de salvar.Run the script that you just saved. Você será solicitado a fornecer as credenciais – use as credenciais de administrador global que você recebeu quando se inscreveu pela primeira vez em sua assinatura de desenvolvedor.You'll be prompted to provide the credentials - use the Global Administrator credentials you received when you first signed up for your developer subscription.

Observação

O script levará vários minutos para executar-não fechar a sessão do PowerShell.The script will take several minutes to execute - do not close your PowerShell session. Se você modificou os usuários em sua assinatura do que foi criado no pacote de conteúdo padrão, alguns usuários podem não ser adicionados ao Teams.If you've modified the users in your subscription from what is created in the default content pack, some users may not be added to teams. À medida que o script é executado, ocorrerá a saída de ações bem-sucedidas ou com falha.As the script executes it will output successful or failed actions.

Após a execução do script, você pode fazer logon no cliente do Microsoft Teams com uma das contas de usuário e exibir as equipes recém-criadas.Once the script has finished execution, you can login to the Teams client with one of the user accounts and view the newly created teams.