Forum Discussion

tkijsurachai's avatar
tkijsurachai
Copper Contributor
Feb 17, 2023

Getting a list of files in private channels in Teams with Sharepoint Powershell

Hello,

 

I'm looking to get a list of files in private channels in Teams using Sharepoint Powershell.  I am able to connect-sposervice and get-sposite, but I am lost afterwards.  Please assist!  Thank you. 

  • tkijsurachai 

     

    To get a list of files in private channels in Teams using SharePoint PowerShell, you can follow these steps:

    1- Connect to the SharePoint Online Service using the Connect-SPOService cmdlet. Here's an example:

     

    Connect-SPOService -Url https://yourdomain-admin.sharepoint.com


    2- Get the Site URL of the Team where the private channel is located. You can do this by running the Get-SPOSite cmdlet and filtering the results by the Team's name. Here's an example:

     

    Get-SPOSite | Where-Object {$_.Title -eq "Your Team Name"} | Select-Object Url
    Note: Replace "Your Team Name" with the name of your Team.

     

    3- Once you have the Site URL of the Team, you can use the Get-SPOList cmdlet to get a list of all the lists in the site. Here's an example:

     

    Get-SPOList -WebUrl https://yourdomain.sharepoint.com/sites/YourTeamName | Select-Object Title
    Note: Replace "YourTeamName" with the name of your Team and "yourdomain" with your domain name.

    4- Identify the name of the list that corresponds to the private channel you're interested in. You can use the Title property of the list to do this.

    5- Once you have the name of the list, you can use the Get-SPOListItem cmdlet to get a list of all the items in the list. Here's an example:


    Get-SPOListItem -ListName "Your List Name" -WebUrl https://yourdomain.sharepoint.com/sites/YourTeamName
    Note: Replace "Your List Name" with the name of the list that corresponds to the private channel you're interested in.

    6- Finally, you can use the FileLeafRef property of each item to get the name of the file. Here's an example:

    Get-SPOListItem -ListName "Your List Name" -WebUrl https://yourdomain.sharepoint.com/sites/YourTeamName | Select-Object FileLeafRef
    Note: Replace "Your List Name" with the name of the list that corresponds to the private channel you're interested in.

    That should give you a list of files in the private channel you're interested in. Keep in mind that you'll need to have the necessary permissions to access the Team's SharePoint site in order to run these commands

    • DrumTech's avatar
      DrumTech
      Copper Contributor

      Varun_Ghildiyal 
      There is an error when attempting line 3 of your suggestion. 
      "The term 'Get-SPOList' is not recognized as the name of a cmdlet"
      A quick search of Google-fu and I see that it doesn't exist. Am I missing something?

Resources