teams
9 TopicsAdd parent team in a shared channel with powershell
Hello, I'm trying to add the team, where my shared channel is, as a member oh this channel but I can't find the good command. The last one I used is : $TeamGrouId = "000-000-000-000" #ID de l'équipe concernée $Channel = "Mon canal partagé" $channelID = (Get-TeamChannel -GroupId $TeamGroupId | Where-Object { $_.DisplayName -Like $Channel}).Id $paramstest = @{ "@odata.type" = "microsoft.graph.aadUserConversationMember" roles = @("member") "*** Adresse électronique supprimée pour cause de confidentialité ***" = "https://graph.microsoft.com/v1.0/groups/$TeamGroupId" } Add-MgTeamChannelMember -TeamId $TeamGroupId -ChannelId $channelId -BodyParameter $paramstest The error message I'm encoutering is : Add-MgTeamChannelMember : Bind requests not expected for action payload. Status: 400 (BadRequest) ErrorCode: BadRequest If anyone have a solution :-) Best regards P.S. : I'm french so my english may be a little bad.6Views0likes0Commentsscript to use PowerShell to Report Teams Status, Presence and Reset After Time
I would like to create a powershell script to run against my tenant to report where people have got a Reset Status After time coded in Teams Any suggestions - greatfully received. I can only find commands to show presence.Solved137Views0likes5CommentsScript for Teams-Chat backup
Sometimes it is necessary to save the chat history of a Teams-Channel. I wrote a simple script, where you can select the needed Team(s) and outputting the Chat-Content to a html File. If there are any comments, I'm open for suggestions. Here is the Script: #Install-Module -Name SharePointPnPPowerShellOnline $SecurityScope = @("Group.Read.All") Connect-PnPOnline -Scopes $SecurityScope $PnPGraphAccessToken = Get-PnPGraphAccessToken ,$Headers = @{ "Content-Type" = "application/json" Authorization = "Bearer $PnPGraphAccessToken" } $Date = Get-Date -Format "dd.MM.yyyy, HH:mm" $DOCTYPE = "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'><html xmlns='http://www.w3.org/1999/xhtml'>" $Style ="<style>table {border-collapse: collapse; width:100%;} table th {text-align:left; background-color: #004C99; color:#fff; padding: 4px 30px 4px 8px;} table td {border: 1px solid #004C99; padding: 4px 8px;} td {background-color: #DDE5FF}</style>" $Head = "<head><title>Backup: Teams-Chat</title></head>" $Body = "<body><div style='width: 100%;'><table><tr><th style='text-align:center'><h1>Backup: Teams-Chat from $Date</h1></th></tr></table>" $Table_body = "<div style='width: 100%;'><table><tr><th>TimeStamp</th><th>User Name</th><th>Message</th></tr>" $Content ="" $Footer = "</body>" $response_teams = Invoke-RestMethod -Uri "https://graph.microsoft.com/beta/groups" -Method Get -Headers $Headers -UseBasicParsing $response_teams.value | Where-Object {$_.groupTypes -eq "Unified"} | Select-Object -Property displayName, ID | Out-GridView -PassThru -Title 'Which Team-Chat do you want to backup?' | ForEach-Object { $Team_ID = $_.ID $Team_displayName = $_.displayName Write-Progress -Activity "Bckup Team Chat Mesasages" -Status "Get Team: $($Team_displayName)" Start-Sleep -Milliseconds 50 $Content += "</br></br><hr><h2>Team: " + $Team_displayName + "</h2>" $response_channels = Invoke-RestMethod -Uri "https://graph.microsoft.com/beta/teams/$Team_ID/channels" -Method Get -Headers $Headers -UseBasicParsing $response_channels.value | Select-Object -Property ID, displayName | ForEach-Object { $Channel_ID = $_.ID $Channel_displayName = $_.displayName Write-Progress -Activity "Bckup Team Chat Mesasages" -Status "Get Channel: $($Channel_displayName)" Start-Sleep -Milliseconds 50 $Content += "<h3>Channel: " + $Channel_displayName + "</h3>" $response_messages = Invoke-RestMethod -Uri "https://graph.microsoft.com/beta/teams/$Team_ID/channels/$Channel_ID/messages" -Method Get -Headers $Headers -UseBasicParsing $response_messages.value | Select-Object -Property ID, createdDateTime, from | ForEach-Object { $Message_ID = $_.ID $Message_TimeStamp = $_.createdDateTime $Message_from = $_.from $response_content = Invoke-RestMethod -Uri "https://graph.microsoft.com/beta/teams/$Team_ID/channels/$Channel_ID/messages/$Message_ID" -Method Get -Headers $Headers -UseBasicParsing Write-Progress -Activity "Bckup Team Chat Mesasages" -Status "Get Team: $($Team_displayName), Gett Message-ID: $($Message_ID), from Channel: $($Channel_displayName)" Start-Sleep -Milliseconds 50 $Content += $Table_body + "<td>" + $Message_TimeStamp + "</td><td style='width: 10%;'>" + $Message_from.user.displayName + "</td><td style='width: 75%;'>" + $response_content.body.content + $response_content.attachments.id + "</td></table></div>" $response_Reply = Invoke-RestMethod -Uri "https://graph.microsoft.com/beta/teams/$Team_ID/channels/$Channel_ID/messages/$Message_ID/replies" -Method Get -Headers $Headers -UseBasicParsing $response_Reply.value | Select-Object -Property ID, createdDateTime, from | ForEach-Object { $Reply_ID = $_.ID $Reply_TimeStamp= $_.createdDateTime $Reply_from = $_.from $response_Reply = Invoke-RestMethod -Uri "https://graph.microsoft.com/beta/teams/$Team_ID/channels/$Channel_ID/messages/$Message_ID/replies/$Reply_ID" -Method Get -Headers $Headers -UseBasicParsing Write-Progress -Activity "Bckup Team Chat Mesasages" -Status "Gett Reply-Message-ID: $($Reply_ID)" Start-Sleep -Milliseconds 50 ForEach-Object { $Content += $Table_body + "<td>" + $Reply_TimeStamp + "</td><td style='width: 10%;'>" + $Reply_from.user.displayName + "</td><td style='width: 75%;'>" + $response_Reply.body.content + $response_Reply.attachments.id + $response_Reply.attachments.name + "</td></table></div>" } } } } } $DOCTYPE + $Style + $Head + $Body + $Content + $Footer | Out-File -FilePath "C:\Backup.html" & "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" "C:\Backup.html"17KViews1like4CommentsHow to automate adding tags to multiple team members at once using PowerShell
I see that there is no way to ease the job of adding a tag to multiple users at the same time without having to look for the user in the edit tag window, so if you have a large list of team members and you want to add the tag to a lot of them or all, it is a little tedious, so exploring the API we can do this, sharing here in case anyone needs this https://get-itips.capazero.net/posts/Add-TagsToUsers2.2KViews1like1CommentAdd user to teams chat
Hi, I want to add an exising user to a team chat with PowerShell, but I can't find a working solution in the documentation or on google, hopefulle someone can help here: I found following commands, but non of them I get to work: New-MgUserChatMember --> Throws error when using Add-MgUserChatMember --> Throws error when using Add-MgChatMember --> I don't know how to build BODYPARAMETERS To my script: first I installed all modules of Microsoft-Graph: Install-Module Microsoft.Graph Find-Module Microsoft.Graph.* | Install-Module Then I connected to MS-Graph: Connect-MgGraph Here I get the user which should be added to the chat(s): $user = Get-MgUser -Filter "UserPrincipalName eq 'email address removed for privacy reasons'" Now get the chat groups where to add the user, and add it with the commands above $groups = Get-MgChat -Filter "ChatType eq 'group'" | Where-Object Topic -in $chatgroups foreach ($group in $groups) { New-MgUserChatMember -UserId $user.Id -ChatId $group.Id Add-MgUserChatMember -UserId $user.Id -ChatId $group.Id } But when I run this I get following error messages: New-MgUserChatMember : Requested API is not supported. Please check the path. At N:\Administration\IT\60 Tools\PowerShell\MS-Teams\SyncMSTeamsChatGroupMembers.ps1:93 char:25 + ... New-MgUserChatMember -UserId $user.Id -ChatId $group.Id + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: ({ UserId = 1fe3...rsationMember }:<>f__AnonymousType197`3) [New-MgUserChatMember_CreateExpanded], RestException` 1 + FullyQualifiedErrorId : NotFound,Microsoft.Graph.PowerShell.Cmdlets.NewMgUserChatMember_CreateExpanded Add-MgUserChatMember : 404 page not found At N:\Administration\IT\60 Tools\PowerShell\MS-Teams\SyncMSTeamsChatGroupMembers.ps1:94 char:25 + ... Add-MgUserChatMember -UserId $user.Id -ChatId $group.Id + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: ({ UserId = 1fe3...ionJsonSchema }:<>f__AnonymousType0`3) [Add-MgUserChatMember_AddExpanded1], RestException`1 + FullyQualifiedErrorId : UnknownError,Microsoft.Graph.PowerShell.Cmdlets.AddMgUserChatMember_AddExpanded1 I also tried to get the command Add-MgChatMember to work, but I don't know how to prepare the BODYPARAMS-Attribute, I tried different settings, but always got:AclCheckFailed-Error, seams missing permissions, but I can access the chat and the user info, but can't update it? Is there a special authentication needed. How to implement this? I would appreciate any help, thanks in advance. Rainer3.1KViews0likes1CommentEWS API - For-Each using User Impersonation
Could someone show me how I would take this script and run it against a list of users? Currently it is only designed to run against the user which is authenticated. I understand the on behalf permissions in Office 365 has to be granted, I just want to know how can I run this against a list of users, perhaps in a text file? function Get-TeamsMeetingsFolder{ param( [Parameter(Position = 1, Mandatory = $true)] [string]$MailboxName, [Parameter(Position = 2, Mandatory = $false)] [string]$AccessToken, [Parameter(Position = 3, Mandatory = $false)] [string]$url, [Parameter(Position = 4, Mandatory = $false)] [switch]$useImpersonation, [Parameter(Position = 5, Mandatory = $false)] [switch]$basicAuth, [Parameter(Position = 6, Mandatory = $false)] [System.Management.Automation.PSCredential]$Credentials, [Parameter(Position =7, Mandatory = $false) ] [Microsoft.Exchange.WebServices.Data.ExchangeService]$service ) Process { if($service -eq $null){ if ($basicAuth.IsPresent) { if (!$Credentials) { $Credentials = Get-Credential } $service = Connect-Exchange -MailboxName $MailboxName -url $url -basicAuth -Credentials $Credentials } else { $service = Connect-EXCExchange -MailboxName $MailboxName -ModernAuth #-AccessToken $AccessToken } $service.HttpHeaders.Add("X-AnchorMailbox", $MailboxName); if ($useImpersonation.IsPresent) { $service.ImpersonatedUserId = new-object Microsoft.Exchange.WebServices.Data.ImpersonatedUserId([Microsoft.Exchange.WebServices.Data.ConnectingIdType]::SmtpAddress, $MailboxName) } } $folderid= new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Root,$MailboxName) $TeamMeetingsFolderEntryId = new-object Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition([System.Guid]::Parse("{07857F3C-AC6C-426B-8A8D-D1F7EA59F3C8}"), "TeamsMeetingsFolderEntryId", [Microsoft.Exchange.WebServices.Data.MapiPropertyType]::Binary); $psPropset= new-object Microsoft.Exchange.WebServices.Data.PropertySet([Microsoft.Exchange.WebServices.Data.BasePropertySet]::FirstClassProperties) $psPropset.Add($TeamMeetingsFolderEntryId) $RootFolder = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($service,$folderid,$psPropset) $FolderIdVal = $null $TeamsMeetingFolder = $null if ($RootFolder.TryGetProperty($TeamMeetingsFolderEntryId,[ref]$FolderIdVal)) { $TeamMeetingFolderId= new-object Microsoft.Exchange.WebServices.Data.FolderId((ConvertId -HexId ([System.BitConverter]::ToString($FolderIdVal).Replace("-","")) -service $service)) $TeamsMeetingFolder = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($service,$TeamMeetingFolderId); } return $TeamsMeetingFolder } }2.2KViews0likes1CommentMove Channels between teams via Powershell Graph API
Yes, I asked this in the teams forum then realized thats probably not the place to ask. So I'm asking here IS there a way to do this via the powershell graph (or any other) api? Or do I have to use C# (.net) thanks for your time brad1.3KViews0likes0Commentspowershell command for checking teams client online status
Hi all, i like to get your help on finding a powershell command for checking teams client online status, preferably i can put my teams client name into a text file, and the powershell can help me check if those teams client are currently online or offline will be my objective. I have done some googling that there are cmdlets available for skype such as get-csOnlineUser https://docs.microsoft.com/en-us/powershell/module/skype/get-csonlineuser?view=skype-ps But so far , i not able to find anything for MS Teams, appreciate if anyone can point me to the right direction on this ? thanks in advance. will something like this works for teams client with some tweaking ? $client = [Microsoft.Lync.Model.LyncClient]::GetClient() $contact = $client.ContactManager.GetContactByUri("spiderman@marvel.com") $availabilityId = $contact.GetContactInformation("Availability") $activity = $contact.GetContactInformation("Activity") Write-Output ([Microsoft.Lync.Model.ContactAvailability]$availabilityId)17KViews0likes1Comment