Tag Archives: PowerShell

Manage the life cycle of private channels in Microsoft Teams

Microsoft has published a very useful article in “Manage the life cycle of private channels in Microsoft Teams”, which can be found here: https://docs.microsoft.com/en-us/microsoftteams/private-channels-life-cycle-management

In this post I have added my thoughts below some of their key points.

Set whether team members can create private channels

Team owners can turn off or turn on the ability for members to create private channels in team settings. To do this, on the Settings tab for the team, turn off or turn on Allow members to create private channels.

Microsoft
Microsoft Teams: Team Settings

As an admin, you can use Graph API, however currently there is not an option available for PowerShell (e.g. using the Set-Team PowerShell cmdlet – version 1.0.3).

Set whether users in your organization can create private channels

As an admin, you can set policies by using the Microsoft Teams admin center or PowerShell to control which users in your organization are allowed to create private channels.

Using the Microsoft Teams admin center

Use teams policies to set which users in your organization are allowed to create private channels. To learn more: https://docs.microsoft.com/en-us/microsoftteams/teams-policies

Microsoft

Using PowerShell

Use CsTeamsChannelsPolicy to set which users in your organization are allowed to create private channels. Set the AllowPrivateChannelCreation parameter to true to allow users who are assigned the policy to create private channels. Setting the parameter to false turns off the ability to create private channels for users who are assigned the policy.

Microsoft

NOTE: This cmdlet is currently (20/11/2019) only available in limited preview in the pre-release Teams PowerShell module.

Create a private channel on behalf of a team owner

As an admin, you can use PowerShell or Graph API to create a private channel on behalf of a team owner. For example, you may want to do this if your organization wants to centralize creation of private channels.

Microsoft

Pretty straight forward, for more information see the links below:

Find SharePoint URLs for all private channels in a team

Whether you’re looking to perform eDiscovery or legal hold on files in a private channel or looking to build a line-of-business app that places files in specific private channels, you’ll want a way to query the unique SharePoint site collections that are created for each private channel.

As an admin, you can use PowerShell or Graph APIs commands to query these URLs.

Microsoft
$sites = get-sposite -template "teamchannel#0" 
$groupID = “<group_id>" 
foreach ($site in $sites) {
  $x= Get-SpoSite -Identity $site.url -Detail; 
  if ($x.RelatedGroupId -eq $groupID) {
    $x.RelatedGroupId;$x.url
  }
} 
GET https://graph.microsoft.com/beta/teams/<group_id>/channels?$filter=membershipType   eq 'private'    

Compliance, eDiscovery and legal hold are all very important considerations when working with SharePoint and Microsoft Teams and I don’t see Private Channels being different. With that in mind, being able to quickly locate and manage the Site Collections (and data) is essential.

Currently there is not way to list and manage site collections created by Private Channel within the SharePoint Admin Center. Plus the PowerShell implementation is lagging behind the Graph API. That said with a little effort we can work around these limitations.

List and update roles of owners and members in a private channel

You may want to list out the owners and members of a private channel to decide whether you need to promote certain members of the private channel to an owner. This can happen when you have owners of private channels who have left the organization and the private channel requires admin help to claim ownership of the channel.

As an admin, you can use PowerShell or Graph APIs commands to query these URLs.

Microsoft

Pretty straight forward, for more information see the links below:

Select: Permanently delete the site collection from the recycle bin...

Deleting SharePoint Online Root Site Collection

Today I had a lengthy conversation with Microsoft Support regarding a number of failures we have been experiencing while deleting and recreation the Root Site Collection for a particular SharePoint Online Tenancy.

I was using the following PowerShell commandlets to delete a site collection:

  • Remove-SPOSite
  • Remove-SPODeletedSite

After running the commands (and checking that the root site collection was no longer in the Recycle Bin) I would attempt to create a new root site collection, but I would intermittently see the following error message:

The site collection already exists. Please enter a different address.

If I repeat the creation action a number of time then it usual resolved itself (e.g. within 15 minutes) and new a site collection would be created. However if process continues to fail for more than an hour then I’ve found through experience it generally would not resolve itself without help from Microsoft Support.

Apparently Microsoft Support resolves the issue by deleting the Root Site Collection from the “Farm Recycle Bin”, another level up (and out of sight of Tenant Admins)…

So what should I do?

Will I was advised (but not as Microsoft policy) to avoid using the specific PowerShell commandlets to deleting/removing a Root Site Collection, but to use the UI (User Interface) instead.

Note: Sub-Site Collections are excluded from this guidance, apparenlty the PowerShell commandlets are still a good option.

These are the steps when using the UI:

  1. Select the Root Site Collection and click Delete
    Select & Delete Root Site Collection
  1. Select the “I understand that nobody can access SharePoint until I create a new site collection at http://YourTenant.sharepoint.com” and click Delete
    I understand that nobody can access SharePoint until...
  1. Navigate to the Recycle Bin
    Navigate to the Recycle Bin
  1. And wait for the processing icon to the right of the URL to disappear
    And wait for the processing icon...
  1. Navigate back the Site Collection page and select new Private Site Collection
    Create a new Private Site Collection
  1. Enter the details for your new Root Site Collection and click OK
    Enter the details for the new site collection......
  1. Review the error messages and then select “Permanently delete the site collection from the recycle bin and continue.” And then click OKSelect: Permanently delete the site collection from the recycle bin...
  1. A message may appear “Your site collection is being created. It can tale 15 minutes or longer to complete this task…”
    our site collection is being created...
  1. And wait for the processing icon to the right of the URL to disappear
    And wait...
  1. The New Root Site Collection has been created.
    Root Site Collection has been created.

So what is happening behind the scenes?

Well unfortunate our conversation was a little broken up by a poor quality phone line but from what I can gather there the UI seems to be able to gather more information from the Server(s) then the PowerShell commandlets…

Virtual Machine: SharePoint failing to create a Web Application

So your Virtual Machine doesn’t quite have enough resources to create a new Web Application using Central Admin, then you have two choices PowerShell or the workaround I’m going to describe today.

Before I describe the workaround let me describe why you might be here in the first place. Normally you would open SharePoint 2013 Central Administration and from the home page click on “Manage web applications”. At this point you click the “New” button, fill out the form and wait. If you are unlucky then you will see the “Something went wrong” screen. Unfortunately SharePoint has probably created a Content Database, an IIS Application Pool and an empty IIS Site. If so then you can try the deleting the assets using the GUI however it will almost certainly fail. Or just run the following PowerShell (and be patient):

Remove-SPWebApplication http://sitename -Confirm -DeleteIISSite -RemoveContentDatabases

The workaround:

Open the Internet Information Services (IIS) Manager window, right click on Application Pools node, select “Add Application Pool…”, enter a name (e.g. “SharePoint – site.domain.com”) and click OK.

One your new Application Pool has been created select it and click on “Advanced Settings…” (on the right, under Actions). And then follow these actions:

  1. Change the Identity to be an AD account
  2. Change Idle Time-out (minutes) from 20 to 0
  3. Change the values for the following properties to 420:
    • Ping Maximum Response Time (seconds)
    • Shutdown Time Limit (seconds)
    • Startup Time Limit (seconds)
  4. Click OK

Now you are ready to create you Web Application using SharePoint 2013 Central Administration. Navigate to “Manage web applications” and click the “New” button. Fill out the form, but this time select your new Application Pool before clicking OK and wait. Assuming all went OK then open the IIS Manager window and navigate back your new Application Pool’s Advanced Settings and change the values for the following properties back to 90:

  • Ping Maximum Response Time (seconds)
  • Shutdown Time Limit (seconds)
  • Startup Time Limit (seconds)

Job done.​