Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions documentation/Get-PnPContainer.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Returns one or more Containers in a SharePoint repository services application.
## SYNTAX

```powershell
Get-PnPContainer [[-Identity] <ContainerPipeBind>] [-OwningApplicationId [Guid]] [-Connection <PnPConnection>]
Get-PnPContainer [[-Identity] <ContainerPipeBind>] [-OwningApplicationId [Guid]] [-Paged [switchparameter]] [-PagingToken [string]][-Connection <PnPConnection>]
```

## DESCRIPTION
Expand Down Expand Up @@ -117,7 +117,7 @@ Accept wildcard characters: False

Use this parameter to provide the <Paging Token> provided to view the remaining Containers as shown in Example 5. If there are no more Containers to display, the commandlet output will return the message End of Containers view. Otherwise, use the given <Paging Token> to retrieve the next batch of up to 5,000 ontainers.
```yaml
Type: SwitchParameter
Type: String
Parameter Sets: (All)

Required: False
Expand Down
80 changes: 80 additions & 0 deletions documentation/Remove-PnPContainer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
---
Module Name: PnP.PowerShell
schema: 2.0.0
applicable: SharePoint Online
online version: https://pnp.github.io/powershell/cmdlets/Remove-PnPContainer.html
external help file: PnP.PowerShell.dll-Help.xml
title: Remove-PnPContainer
---

# Remove-PnPContainer

## SYNOPSIS

**Required Permissions**

* SharePoint: Access to the SharePoint Tenant Administration site

The Remove-PnPContainer cmdlet removes a container from the SharePoint tenant. The container to remove is specified by the Identity parameter, which accepts a ContainerPipeBind object.

## SYNTAX

```powershell
Remove-PnPContainer [-Identity] <ContainerPipeBind> [-Connection <PnPConnection>]
```

## DESCRIPTION

## EXAMPLES

### EXAMPLE 1

```powershell
Remove-PnPContainer -Identity "b!aBrXSxKDdUKZsaK3Djug6C5rF4MG3pRBomypnjOHiSrjkM_EBk_1S57U3gD7oW-1"
```

Removes the specified container by using the container id.

### EXAMPLE 2

```powershell
Remove-PnPContainer -Identity "https://contoso.sharepoint.com/contentstorage/CSP_4bd71a68-8312-4275-99b1-a2b70e3ba0e8"
```

Removes the the specified container by using the container url

## PARAMETERS

### -Connection

Optional connection to be used by the cmdlet. Retrieve the value for this parameter by either specifying -ReturnConnection on Connect-PnPOnline or by executing Get-PnPConnection.

```yaml
Type: PnPConnection
Parameter Sets: (All)

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -Identity

Specify container site url or container id.

```yaml
Type: ContainerPipeBind
Parameter Sets: (All)

Required: Falsegit
Position: 0
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
```

## RELATED LINKS

[Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp)
22 changes: 22 additions & 0 deletions src/Commands/Admin/RemoveContainer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Microsoft.Online.SharePoint.TenantAdministration;
using Microsoft.SharePoint.Client;
using PnP.PowerShell.Commands.Base;
using System.Management.Automation;
using PnP.PowerShell.Commands.Base.PipeBinds;

namespace PnP.PowerShell.Commands.Admin
{
[Cmdlet(VerbsCommon.Remove, "PnPContainer")]
public class RemoveContainer : PnPAdminCmdlet
{
[Parameter(Mandatory = true)]
public ContainerPipeBind Identity { get; set; }

protected override void ExecuteCmdlet()
{
var containerProperties = Identity.GetContainer(Tenant);
Tenant.RemoveSPOContainerByContainerId(containerProperties.ContainerId);
AdminContext.ExecuteQueryRetry();
}
}
}