Private channel creation date export

MS 426 Reputation points
2022-10-04T19:33:30.663+00:00

Hi Experts,

We have all Private channels exported in the csv file (Group Ids of the teams), could you please provide a script to export the creation date of the private channels based on the group IDs of the Teams in the CSV file.

Thanks in Advance.

Regards,
MS

Windows for business | Windows Server | User experience | PowerShell
Microsoft Teams | Microsoft Teams for business | Other
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Kael Yao 37,746 Reputation points Moderator
    2022-10-05T03:06:39.943+00:00

    Hi @MS

    In Teams Powershell there is no cmdlet to get the creation date of a channel.
    While we may use the Unified Audit Log (events within 90days) to search for the event (Added channel) and then filter the results for the specific private channels.

    Below is an example:
    247608-69.png
    247641-70.png


    If this method cannot meet your requirement, Microsoft Graph Api would also be a solution.

    If you need further help on with Graph Api, please consider creating a new post and adding the related tags to get better support.
    Thanks for your understanding.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

  2. Kevin Morgan 6 Reputation points
    2022-10-05T11:23:48.637+00:00

    You can use Microsoft Graph PowerShell SDK to get all private channels along with the creation date.

    Get started with the Microsoft Graph PowerShell SDK

    Source : Updated version of this script : Export All Private Channels using Teams PowerShell

    $Result = @() #Result array  
      
    #Connect Microsoft Graph  
    $RequiredScopes = @("Group.Read.All", "ChannelSettings.Read.All")  
    Connect-MgGraph -Scopes $RequiredScopes  
       
    #Get all teams  
    $AllTeams= Get-MgGroup -Filter "resourceProvisioningOptions/Any(x:x eq 'Team')"  
    $TotalTeams = $AllTeams.Count  
    $i = 0  
       
    #Iterate teams one by one and gets private channels   
    ForEach ($Team in $AllTeams)  
    {  
    $i++  
    Write-Progress -Activity "Discover private channels in $($Team.Displayname)" -Status "$i out of $TotalTeams teams completed"  
       
    Try  
    {  
    #Get private channels  
    $PrivateChannels = Get-MgTeamChannel -TeamId $Team.Id -Filter "membershipType eq 'private'"  
        
    #Iterate channels one by one and adds to the result array  
    ForEach ($Channel in $PrivateChannels)  
    {  
    #Add channel info to the result array  
    $Result += New-Object PSObject -property $([ordered]@{  
    TeamName = $Team.DisplayName  
    GroupId = $Team.GroupId  
    GroupCreatedDate = $Team.CreatedDateTime  
    ChannelName = $Channel.DisplayName  
    ChannelId = $Channel.Id  
    Description = $Channel.Description  
    ChannelCreatedDate = $Channel.CreatedDateTime  
      
    })  
        
    }  
    }  
    Catch   
    {  
    Write-Host "Error occurred for $($Team.Displayname)" -f Yellow  
    Write-Host $_ -f Red  
    }  
    }  
        
    #Export the result to CSV file  
    $Result | Export-CSV "C:\Temp\AllPrivateChannels.CSV" -NoTypeInformation -Encoding UTF8  
    
    0 comments No comments

  3. Limitless Technology 39,921 Reputation points
    2022-10-06T09:56:54.93+00:00

    Hello there,

    Most of the scripts works only when you are the member of the team yourself.Before running the script you need to make sure you run Connect-MicrosoftTeams and Connect-ExchangeOnline.

    $AllTeamsInOrg = (Get-Team).GroupID
    $TeamList = @()

    Write-Output "This may take a little bit of time... Please sit back, relax and enjoy some GIFs inside of Teams!"
    Write-Host ""

    Foreach ($Team in $AllTeamsInOrg)
    {
    $TeamGUID = $Team.ToString()
    $TeamGroup = Get-UnifiedGroup -identity $Team.ToString()
    $TeamName = (Get-Team | ?{$.GroupID -eq $Team}).DisplayName
    $TeamOwner = (Get-TeamUser -GroupId $Team | ?{$
    .Role -eq 'Owner'}).User
    $TeamUserCount = ((Get-TeamUser -GroupId $Team).UserID).Count
    $TeamGuest = (Get-UnifiedGroupLinks -LinkType Members -identity $Team | ?{$_.Name -match "#EXT#"}).Name
    if ($TeamGuest -eq $null)
    {
    $TeamGuest = "No Guests in Team"
    }
    $TeamChannels = (Get-TeamChannel -GroupId $Team).DisplayName
    $ChannelCount = (Get-TeamChannel -GroupId $Team).ID.Count
    $TeamList = $TeamList + [PSCustomObject]@{TeamName = $TeamName; TeamObjectID = $TeamGUID; TeamOwners = $TeamOwner -join ', '; TeamMemberCount = $TeamUserCount; NoOfChannels = $ChannelCount; ChannelNames = $TeamChannels -join ', '; SharePointSite = $TeamGroup.SharePointSiteURL; AccessType = $TeamGroup.AccessType; TeamGuests = $TeamGuest -join ','}
    }

    Get all Teams and channel information using PowerShell u
    https://techcommunity.microsoft.com/t5/microsoft-teams/get-all-teams-and-channel-information-using-powershell/m-p/1312145

    ---------------------------------------------------------------------------------------------------------------------------------------------

    --If the reply is helpful, please Upvote and Accept it as an answer--

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.