MS Teams

Hi Team.

Is anyone managing MS Teams in anyway with ARS? 

We would like to delegate the ability to a select few service desk people to be able to create MS Teams channels. 

We have a Powershell script that can do it. Is there an easy way maybe of having them execute the PS from within ARS? 

Parents
  • The Powershell code we have to do this manually is below. Do we think we could have this run from within ARS? 

    $time = Get-Date -Format "yyyy-MM-dd-HH-mm"
    $logfile = "C:\temp\CreateTeams_task-$time.txt"
    Start-Transcript -Path $logfile -Append
    
    function Create-Channel {   
        param (   
            $ChannelName, $GroupId
        )   
        Process {
            try {
                $teamchannels = $ChannelName -split ";" 
                  if ($teamchannels) {
                    for ($i = 0; $i -le ($teamchannels.count - 1) ; $i++) {
                        New-TeamChannel -GroupId $GroupId -DisplayName $teamchannels[$i]
                    }
                }
            }
            Catch {
            }
        }
    }
    
    function Add-Users {   
        param(   
            $Users, $GroupId, $CurrentUsername, $Role
        )   
        Process {
            
            try {
                $teamusers = $Users -split ";" 
                if ($teamusers) {
                    for ($j = 0; $j -le ($teamusers.count - 1) ; $j++) {
                        if ($teamusers[$j] -ne $CurrentUsername) {
                            Add-TeamUser -GroupId $GroupId -User $teamusers[$j] -Role $Role
                        }
                    }
                }
            }
            Catch {
            }
        }
    }
    
    function Create-NewTeam {   
        param (   
            $ImportPath
        )   
        Process {
            Import-Module MicrosoftTeams
            $username = $cred.UserName
            $teams = Import-Csv -Path $ImportPath
            foreach ($team in $teams) {
                $getteam = get-team | where-object { $_.displayname -eq $team.'Team workspaces' }
                If ($getteam -eq $null) {
                    Write-Host "Start creating the team: " $team.'Team workspaces'
                    $group = New-Team -displayname $team.'Team workspaces' -Owner $team.'Owners 1' -MailNickName $team.MailNickName  -Visibility Private -AllowCreateUpdateChannels $false -AllowCreatePrivateChannels $false -AllowAddRemoveApps $false -AllowCreateUpdateRemoveTabs $false -AllowCreateUpdateRemoveConnectors $false -GiphyContentRating Strict -AllowDeleteChannels $false -AllowUserDeleteMessages $false -AllowOwnerDeleteMessages $false -AllowUserEditMessages $false
                    Write-Host "Adding team Owners..."
                    Add-Users -Users $team.Allowners -GroupId $group.GroupId -CurrentUsername $username  -Role owner 
                    Write-Host "Adding team Members..." -ForegroundColor Yellow
                    Add-Users -Users $team.Allmembers -GroupId $group.GroupId -CurrentUsername $username  -Role member 
                    Write-Host "Completed creating the team: " $team.'Team workspaces'
                    $team = $null
                }
                Elseif($getteam -ne $null) {
                $teamname = $team.'Team workspaces'
                write-host "Team: $teamname exists " -ForegroundColor Black -BackgroundColor Magenta
                $teamname =$null
                }
            }
        }
    }
    
    Create-NewTeam -ImportPath "C:\__Powershell\Teams\data\CreateBulkTeams-230922.csv"
    
    Stop-Transcript
    

Reply
  • The Powershell code we have to do this manually is below. Do we think we could have this run from within ARS? 

    $time = Get-Date -Format "yyyy-MM-dd-HH-mm"
    $logfile = "C:\temp\CreateTeams_task-$time.txt"
    Start-Transcript -Path $logfile -Append
    
    function Create-Channel {   
        param (   
            $ChannelName, $GroupId
        )   
        Process {
            try {
                $teamchannels = $ChannelName -split ";" 
                  if ($teamchannels) {
                    for ($i = 0; $i -le ($teamchannels.count - 1) ; $i++) {
                        New-TeamChannel -GroupId $GroupId -DisplayName $teamchannels[$i]
                    }
                }
            }
            Catch {
            }
        }
    }
    
    function Add-Users {   
        param(   
            $Users, $GroupId, $CurrentUsername, $Role
        )   
        Process {
            
            try {
                $teamusers = $Users -split ";" 
                if ($teamusers) {
                    for ($j = 0; $j -le ($teamusers.count - 1) ; $j++) {
                        if ($teamusers[$j] -ne $CurrentUsername) {
                            Add-TeamUser -GroupId $GroupId -User $teamusers[$j] -Role $Role
                        }
                    }
                }
            }
            Catch {
            }
        }
    }
    
    function Create-NewTeam {   
        param (   
            $ImportPath
        )   
        Process {
            Import-Module MicrosoftTeams
            $username = $cred.UserName
            $teams = Import-Csv -Path $ImportPath
            foreach ($team in $teams) {
                $getteam = get-team | where-object { $_.displayname -eq $team.'Team workspaces' }
                If ($getteam -eq $null) {
                    Write-Host "Start creating the team: " $team.'Team workspaces'
                    $group = New-Team -displayname $team.'Team workspaces' -Owner $team.'Owners 1' -MailNickName $team.MailNickName  -Visibility Private -AllowCreateUpdateChannels $false -AllowCreatePrivateChannels $false -AllowAddRemoveApps $false -AllowCreateUpdateRemoveTabs $false -AllowCreateUpdateRemoveConnectors $false -GiphyContentRating Strict -AllowDeleteChannels $false -AllowUserDeleteMessages $false -AllowOwnerDeleteMessages $false -AllowUserEditMessages $false
                    Write-Host "Adding team Owners..."
                    Add-Users -Users $team.Allowners -GroupId $group.GroupId -CurrentUsername $username  -Role owner 
                    Write-Host "Adding team Members..." -ForegroundColor Yellow
                    Add-Users -Users $team.Allmembers -GroupId $group.GroupId -CurrentUsername $username  -Role member 
                    Write-Host "Completed creating the team: " $team.'Team workspaces'
                    $team = $null
                }
                Elseif($getteam -ne $null) {
                $teamname = $team.'Team workspaces'
                write-host "Team: $teamname exists " -ForegroundColor Black -BackgroundColor Magenta
                $teamname =$null
                }
            }
        }
    }
    
    Create-NewTeam -ImportPath "C:\__Powershell\Teams\data\CreateBulkTeams-230922.csv"
    
    Stop-Transcript
    

Children
No Data