11### Create a new team
22
3+ PowerShell:
4+
5+ ``` powershell
6+ $TeamName = "2020 Interns"
7+ $body = ConvertTo-Json '{"displayName": $TeamName, "description": $TeamName, "additionalProperties": { "[email protected] ": "https://graph.microsoft.com/v1.0/teamsTemplates('standard')"}}' 8+ mgc teams create --body $body
9+ ```
10+
11+ Bash:
12+
313``` sh
4- mgc teams create --body ' {"displayName": "2020 Interns", "description": "2020 Interns", \
14+ TeamName = " 2020 Interns"
15+ mgc teams create --body ' {"displayName": $TeamName, "description": $TeamName,
516 "additionalProperties": {
6- "[email protected] " = "https://graph.microsoft.com/v1.0/teamsTemplates(' standard
' )"17+ "[email protected] ": "https://graph.microsoft.com/v1.0/teamsTemplates(' standard
' )"718 }}'
819```
920
1021### Filter groups by displayName and resourceProvisioningOptions to find team
1122
23+ PowerShell:
24+
25+ ``` powershell
26+ $InternsTeam = mgc groups list --filter "StartsWith(DisplayName, '$TeamName')" --query "value[?contains(resourceProvisioningOptions, 'Team')]"
27+ ```
28+
29+ Bash:
30+
1231``` sh
13- mgc groups list --filter " StartsWith(DisplayName, '$TeamName ')" --query " value[?contains(resourceProvisioningOptions, 'Team')]"
32+ InternsTeam= $( mgc groups list --filter " StartsWith(DisplayName, '$TeamName ')" --query " value[?contains(resourceProvisioningOptions, 'Team')]" )
1433```
1534
1635### Add team owner
1736
37+ PowerShell:
38+
39+ ``` powershell
40+ $teamOwner=mgc users get --user-id "{TEAM_OWNER_UPN}"
41+ mgc teams item members create --team-id $InternsTeam.id --body '{"additionalProperties": {
42+ "@odata.type": "#microsoft.graph.aadUserConversationMember",
43+ "[email protected] ": "https://graph.microsoft.com/v1.0/users/" + $teamOwner.id 44+ }, "roles": ["owner"]}'
45+ ```
46+
47+ Bash:
48+
1849``` sh
19- mgc users get --user-id " {TEAM_OWNER_UPN}"
20- mgc teams item members create --team-id < TeamId> --body ' {"additionalProperties": {\
21- "@odata.type": "#microsoft.graph.aadUserConversationMember",\
22- "[email protected] ": "https://graph.microsoft.com/v1.0/users/" + $teamOwner.id\ 50+ teamOwnerId=$( mgc users get --user-id " {TEAM_OWNER_UPN}" | grep -o ' "id": "[^"]*' | grep -o ' [^"]*$' )
51+ teamId=$( echo $InternsTeam | grep -o ' "id": "[^"]*' | grep -o ' [^"]*$' )
52+
53+ mgc teams item members create --team-id $teamId --body ' {"additionalProperties": {
54+ "@odata.type": "#microsoft.graph.aadUserConversationMember",
55+ "[email protected] ": "https://graph.microsoft.com/v1.0/users/" + $teamOwnerId 2356 }, "roles": ["owner"]}'
2457```
2558
2659### Send a welcome message to the channel
2760
61+ PowerShell:
62+
63+ ``` powershell
64+ $PrimaryChannel = mgc teams item primary-channel get --team-id $InternsTeam.id
65+ $body = ConvertTo-Json '{"body": {"content": "Welcome to Teams!"}}'
66+ mgc teams item channels item messages create --team-id $InternsTeam.id --channel-id $PrimaryChannel.id --body $body
67+ ```
68+
69+ Bash:
70+
2871``` sh
29- mgc teams item primary-channel get --team-id < TeamId >
30- mgc teams item channels item messages create --team-id < TeamId > --channel-id < ChannelId > --body ' {"body": {"content": "Welcome to Teams!"}}'
72+ PrimaryChannelId= $( mgc teams item primary-channel get --team-id $teamId | grep -o ' "id": "[^"]* ' | grep -o ' [^"]*$ ' )
73+ mgc teams item channels item messages create --team-id $teamId --channel-id $PrimaryChannelId --body ' {"body": {"content": "Welcome to Teams!"}}'
3174```
3275
3376### Delete team
3477
78+ PowerShell:
79+
80+ ``` powershell
81+ mgc groups delete --group-id $InternsTeam.id
82+ ```
83+
84+ Bash:
85+
3586``` sh
36- mgc groups delete --group-id < GroupId >
87+ mgc groups delete --group-id $teamId
3788```
3889
3990### Teams Chat snippets
@@ -58,8 +109,22 @@ mgc chats item messages create --chat-id <ChatId> --body '{"body": {"content": "
58109
59110#### Mention a user in a channel message
60111
112+ PowerShell:
113+
114+ ``` powershell
115+ $user = mgc users item get --user-id <UserId> --select "id, displayName, userIdentityType"
116+ $body = ConvertTo-Json '{"body": {"contentType": "html", "content": "Welcome to the channel <at id=\'0\'>${user.displayName}</at>!"}, "mentions": [{"id": 0, "mentionText": "${user.displayName}", "mentioned": {"user": {"id": "${user.id}", "displayName": "${user.displayName}", "userIdentityType": "${user.userIdentityType}"}}}]}'
117+ mgc teams item channels item messages create --team-id <TeamId> --channel-id $PrimaryChannel.id \
118+ --body $body
119+ ```
120+
121+ Bash:
122+
61123``` sh
62- mgc users item get --user-id < UserId> --select " id, displayName, userIdentityType"
63- mgc teams item channels item messages create --team-id < TeamId> --channel-id < ChannelId> \
64- --body $' {"body": {"contentType": "html", "content": "Welcome to the channel <at id=\' 0\' >[DisplayName]</at>!"}, "mentions": [{"id": 0, "mentionText": "[DisplayName]", "mentioned": {"user": {"id": "[id]", "displayName": "[DisplayName]", "userIdentityType": "aadUser"}}}]}'
124+ user=$( mgc users item get --user-id < UserId> --select " id, displayName, userIdentityType" )
125+ userId=$( echo $user | grep -o ' "id": "[^"]*' | grep -o ' [^"]*$' )
126+ userDisplayName=$( echo $user | grep -o ' "displayName": "[^"]*' | grep -o ' [^"]*$' )
127+ userIdentityType=$( echo $user | grep -o ' "userIdentityType": "[^"]*' | grep -o ' [^"]*$' )
128+ mgc teams item channels item messages create --team-id < TeamId> --channel-id $PrimaryChannelId \
129+ --body ' {"body": {"contentType": "html", "content": "Welcome to the channel <at id=\' 0\' > ${userDisplayName} < /at> ! " }, " mentions" : [{" id" : 0, " mentionText" : " ${userDisplayName} " , " mentioned" : {" user" : {" id" : " ${userId} " , " displayName" : " ${userDisplayName} " , " userIdentityType" : " ${userIdentityType} " }}}]}'
65130` ` `
0 commit comments