powershell
59 TopicsRenewing Teams over PowerShell in bulk / exclude in bulk from policy.
Hey guys, Just recently have turned on group expiration policy for one client, we done a research and it appeared a great idea, however after some time we got a feedback that some teams need to go back to their documents even 3 years after the Teams channel gets created. And here is the question: is is possible to renew Teams / Outlook Groups in bulk using PowerShell? This particular team told us that they got like hundreds of groups, and renewing them even once a year is a pain. Or maybe there is a way to exclude particular Teams from participating in policy? Appreciat eyour help, Kind regards, J4.5KViews0likes8CommentsRetrieving SharePoint Site Visitors Using PowerShell Script
I’m working on a PowerShell script to generate a report of Microsoft Teams details, including the owners, members, and SharePoint site visitors. While the script successfully retrieves most of the information, it fails to retrieve the site visitors, which I can clearly see in the SharePoint Admin Center. Issues: Site Visitors Not Retrieved: Despite having site visitors visible in the SharePoint Admin Center, the script returns "Error retrieving Visitors" or an empty string for site visitors. Potential Errors: I'm using a try-catch block to handle exceptions, but it seems like there are no errors being caught that could indicate why the visitors aren't being retrieved. What I’ve Tried: Ensured the SharePoint site URL is correct. Checked permissions and roles for the account running the script. Request: Could someone help identify what might be going wrong or suggest a different approach to reliably retrieve the list of SharePoint site visitors or any module I am missing on? I am using below modules with Powershell Runtime version 5.1. ExchangeOnlineManagement - Version 3.5.1 Get-MsolUserLicences - Version 0.0.8 Microsoft.Graph.Authentication - Version 2.20.0 Microsoft.Graph.Teams - Version 2.20.0 Microsoft.Graph.Users - Version 2.20.0 Microsoft.Online.SharePoint.PowerShell - Version 16.0.25012.12000 MicrosoftTeams - Version 6.4.0 MSOnline - Version 1.1.183.81 PackageManagement - Version 1.4.8.1 PnP.PowerShell - Version 2.5.0 PowerShellGet - Version 2.2.5 SharePointPnPPowerShellOnline - Version 3.29.2101.0 Any insights or recommendations would be greatly appreciated! Thanks in advance for your help. Connect-MicrosoftTeams -Credential $UserCredential -AccountId $myCredential.UserName Connect-ExchangeOnline -Credential $UserCredential -ShowProgress $true Connect-SPOService -Url "https://domain-admin.sharepoint.com" -Credential $UserCredential # Initialize an empty array to store the results $Result = @() # Get all Teams enabled groups $AllTeamsInOrg = Get-Team $Teamcount = $AllTeamsInOrg.Count foreach ($Team in $AllTeamsInOrg) { Write-Host "Processing Team $($Team.DisplayName) ..." -NoNewline -ForegroundColor Gray $TeamName = $Team.DisplayName $TeamGroupId = $Team.GroupId # Get team details $TeamOwner = (Get-TeamUser -GroupId $TeamGroupId -Role Owner).User $TeamUserCount = (Get-TeamUser -GroupId $TeamGroupId).Count $TeamGuest = (Get-TeamUser -GroupId $TeamGroupId -Role Guest).Name if ($TeamGuest -eq $null) { $TeamGuest = "No Guests in Team" } $TeamMembers = (Get-TeamUser -GroupId $TeamGroupId -Role Member).User $TeamChannels = (Get-TeamChannel -GroupId $TeamGroupId).DisplayName $ChannelCount = (Get-TeamChannel -GroupId $TeamGroupId).Count # Retrieve SharePoint site URL from the team $TeamGroup = Get-UnifiedGroup -Identity $TeamGroupId $SharePointSiteURL = $TeamGroup.SharePointSiteURL if ($SharePointSiteURL -ne $null) { try { # Get all SharePoint Online groups for the site $SiteGroups = Get-SPOSiteGroup -Site $SharePointSiteURL # Find the "Visitors" group and get its members $VisitorsGroup = $SiteGroups | Where-Object { $_.Title -eq "Visitors" } if ($VisitorsGroup) { $Visitors = Get-SPOSiteGroup -Site $SharePointSiteURL -Group $VisitorsGroup.Title | Select-Object -ExpandProperty Users $VisitorsEmails = $Visitors | Select-Object -ExpandProperty Email -join ", " $GroupsData += [pscustomobject]@{ 'Site URL' = $SharePointSiteURL 'Group Name' = $VisitorsGroup.Title 'Users' = $VisitorsEmails } } else { $GroupsData += [pscustomobject]@{ 'Site URL' = $SharePointSiteURL 'Group Name' = "Visitors" 'Users' = "No Visitors Group Found" } } } catch { Write-Host "Error processing site ${SharePointSiteURL}: $($_.Exception.Message)" -ForegroundColor Red $GroupsData += [pscustomobject]@{ 'Site URL' = $SharePointSiteURL 'Group Name' = "Visitors" 'Users' = "Access Denied or Error" } } } else { $GroupsData += [pscustomobject]@{ 'Site URL' = $SharePointSiteURL 'Group Name' = "Visitors" 'Users' = "No SharePoint Site URL" } } # Add team details to the $Result array $Result += [PSCustomObject]@{ TeamName = $TeamName TeamOwners = $TeamOwner -join ', ' TeamMemberCount = $TeamUserCount TeamMembers = $TeamMembers -join ', ' NoOfChannels = $ChannelCount ChannelNames = $TeamChannels -join ', ' SharePointSite = $SharePointSiteURL AccessType = $TeamGroup.AccessType TeamGuests = $TeamGuest -join ',' SharePointSiteVisitors = $SharePointSiteVisitors } Write-Host "done." -ForegroundColor Green }967Views0likes0CommentsWhat happens if you add a user twice to a team using add-teamuser in Powershell?
Hi, I have the following question: In Powershell using the cmdlet add-teamuser, I can add users to a team. But what happens if you add a user twice to a team? Or in other words: What happens, if you add a user that exists already in the team? Would Powershell ignore the action or would it re-add the user? Would this possibly delete what the user did in the team before (for example his posts or his tasks as a pupil)? Should I check first if the user exists already in the course to avoid possible negative affects?445Views0likes2CommentsUsing PowerShell to Post Channel Messages with Teams Workflows
The incoming webhook connector is a popular method to post information to Teams channels, but Microsoft seems set on retiring the Office connectors. The Teams post to channel workflow when a webhook request is received seems like is a possible replacement, but it’s not just a matter of switching mechanisms. Some PowerShell magic is needed to create a suitable adaptive card to post to the channel, which is exactly what we explain how to do here. https://office365itpros.com/2024/06/17/teams-post-to-channel-workflow/4.5KViews0likes0CommentsWorking with Teams Messaging Using the Microsoft Graph PowerShell SDK
This article describes how to use the Microsoft Graph PowerShell SDK to interact with Teams messaging to create new one-to-one and group chats and post base topics and replies to chats and channel conversations. https://practical365.com/teams-messaging-powershell/296Views0likes0CommentsSending Urgent Teams Chats with PowerShell
A reader asked if it is possible to script sending chat messages. In this article, we explore how to compose and send Teams urgent messages to a set of recipients using Microsoft Graph PowerShell SDK cmdlets. The conversation with each recipient is a one-to-one chat that Teams either creates from scratch or reuses (if a suitable one-on-one chat exists). https://office365itpros.com/2024/04/24/teams-urgent-message-ps/1.9KViews1like1CommentModifying the Teams Tenant Federation Configuration with PowerShell
A new parameter for the Set-CsTenantFederationConfiguration cmdlet made me look at the Teams tenant federation configuration again to improve how a script works. Instead of taking all the domains guest accounts came from and adding them to the configuration, I created a function to check if the tenant uses Microsoft 365. If it does, we add the tenant to the allow list in the tenant federation configuration. If not, we ignore the domain. https://office365itpros.com/2024/04/09/tenant-federation-configuration/544Views0likes0CommentsPowershell command to export ALL private Teams memberships, including private Channel memberships
There is currently a major issue that Microsoft is not saying is a bug. When a user is soft-deleted (what happens when we disconnect that user from the on-premise AD to force the cloud-only conversion) they are soft-deleted in O365. The restore works great, however, Teams does not work afterwards.. When the account is restored, all the licenses are retained, all the email, security, private teams memberships are also restored, however, the private channel memberships are permanently removed and cannot be recovered. The only way to get the access back is to go into Teams Admin Centre, open each Team/Channel combo and re-add the user. What happens if you don't actually know what private channel they are members of and what that membership is (member/owner)? You're SOL. I've tried many powershell scripts but they won't show me ALL private teams with all private channel memberships for all teams/channels/users. I would nave to run it for each team/channel name combo and we have many. Anyone have a good script to use?Solved17KViews1like9CommentsSetting External access options via powershell
Hi. I'm trying to set External access for Teams, but via powershell. Specifically the "Users can communicate with Skype users" option. I can successfully set the "Users can communicate with other Skype for Business and Teams users", but I can't find a solution for the other option ("Users can communicate with Skype users"). I have read numbers of blog postings, tutorials for the mentioned subject but it just doesn't work, the option won't switch. Most mentioned powershell command for doing it, is the following: Set-CsExternalAccessPolicy -EnableOutsideAccess $False Set-CsExternalAccessPolicy -EnableFederationAccess $False Set-CsExternalAccessPolicy -EnablePublicCloudAccess $False Set-CsExternalAccessPolicy -EnablePublicCloudAudioVideoAccess $False And while the script changes the targeted parameters successfully, the switch in the GUI still remains in "ON" position. I Have set the switch to the "OFF" position by hand, but underlying parameters quoted in code block above, haven't changed (their values retrieved with Get-CsExternalAccessPolicy powershell command. So, from that, it seems that those commands aren't for that option after all.. Any help is appreciated. Br19KViews0likes11Comments