The script creates a new team for a user in Microsoft Teams. The script requires the MicrosoftTeamsPowerShell module to be installed on the computer where Adaxes service runs. To execute the script, create a custom command configured for the User object type. The user on which the command is executed will be set as the new team owner.
Parameters:
- $teamNameParamName - Specifies the name of the parameter used to enter the team name with the param- prefix. The parameter must be of the Edit box type.
- $teamVisibilityParamName - Specifies the name of the parameter used to select the team visibility with the param- prefix. The parameter must be of the Drop-down list type with the following values only:
- Public
- Private
PowerShell
$teamNameParamName = "param-teamName" # TODO: modify me
$teamVisibilityParamName = "param-visibility" # TODO: modify me
if ($NULL -eq $Context.TargetObject.AzureId)
{
$Context.LogMessage("The user doesn't have an account in Microsoft 365", "Warning")
return
}
# Get parameter values
$teamName = $Context.GetParameterValue($teamNameParamName)
$teamVisibility = $Context.GetParameterValue($teamVisibilityParamName)
# Get access tokens for Graph API and Microsoft Teams
$graphToken = $Context.CloudServices.GetAzureAuthAccessToken()
$teamsToken = $Context.CloudServices.GetAzureAuthAccessToken("48ac35b8-9aa8-4d74-927d-1f4a14a0b239")
try
{
# Connect to Microsoft Teams
Connect-MicrosoftTeams -AccessTokens @($graphToken, $teamsToken)
# Create new team
New-Team -DisplayName $teamName -Visibility $teamVisibility -Owner $Context.TargetObject.AzureId
}
finally
{
# Close the connection and release resources
Disconnect-MicrosoftTeams -Confirm:$False
}
IS there anyway to add parameters for a owner and members?
To specify an owner for a new team, use the corresponding parameter of the New-Team cmdlet. As for members, they can only be added after the team is already created. For examples, have a look at the Microsoft article: https://learn.microsoft.com/en-us/powershell/module/microsoftteams/new-team?view=teams-ps.
Create a Microsoft Teams Group - 1 operation executed
Run PowerShell script 'Create MS Team' for the user
[Error] The term 'Disconnect-MicrosoftTeams' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again. Stack trace: at <ScriptBlock>, <No file>: line 29
[Error] The term 'Connect-MicrosoftTeams' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again. Stack trace: at <ScriptBlock>, <No file>: line 21
Let me know what I am missing.
Unfortunately, this is a known issue related to the changes Microsoft made for the MicrosoftTeams PowerShell module in the latest versions. As per our investigation, the 6.9.0 version of the module definitely works with Adaxes. Please uninstall all versions of the module and install version 6.9.0 on the computer where the Adaxes service runs. After the installation, restart the Softerra Adaxes Service Windows service. To install the required version, use the following command: