Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding -Detailed option to Get-PnPTenantDeletedSite #3550

Merged
merged 5 commits into from
Nov 10, 2023
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- Added `RestrictedAccessControl`, `ClearRestrictedAccessControl`, `RemoveRestrictedAccessControlGroups`, `AddRestrictedAccessControlGroups` and `RestrictedAccessControlGroups` parameters to `Set-PnPTenantSite` cmdlet to handle restricted access control. [#3463](https://github.com/pnp/powershell/pull/3463)
- Added `Get-PnPRetentionLabel` cmdlet to retrieve Purview retention labels. [#3459](https://github.com/pnp/powershell/pull/3459)
- Added GCC support for `Get-PnPAzureADUser` , `Add-PnPFlowOwner` , `Remove-PnPFlowOwner`, `Sync-PnPSharePointUserProfilesFromAzureActiveDirectory`, `New-PnPAzureADUserTemporaryAccessPass` and `Get-PnPAvailableSensitivityLabel` cmdlets. [#3484](https://github.com/pnp/powershell/pull/3484)
- Added `-Detailed` option to `Get-PnPTenantDeletedSite` to optionally fetch more information on the deleted sites [#3550](https://github.com/pnp/powershell/pull/3550)
- Added a devcontainer for easily building a minimal environment necessary to contribute to the project. [#3497](https://github.com/pnp/powershell/pull/3497)
- Added `-RelativeUrl` parameter to `Connect-PnPOnline` cmdlet to allow specifying custom URLs for usage with `-WebLogin` method. [#3530](https://github.com/pnp/powershell/pull/3530)
- Added `-RetryCount` to `Submit-PnPSearchQuery` which allows for specifying the number of retries to perform when an exception occurs [#3528](https://github.com/pnp/powershell/pull/3528)
Expand Down
62 changes: 41 additions & 21 deletions documentation/Get-PnPTenantDeletedSite.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ Fetches the site collections from the tenant recycle bin.
## SYNTAX

```powershell
Get-PnPTenantDeletedSite [-Identity] <String> [-Limit] [-IncludePersonalSite] [-IncludeOnlyPersonalSite] [-Connection <PnPConnection>]
Get-PnPTenantDeletedSite [-Identity] <String> [-Limit] [-IncludePersonalSite] [-IncludeOnlyPersonalSite] [-Detailed] [-Verbose] [-Connection <PnPConnection>]
```

## DESCRIPTION
Fetches the site collection's which are listed in your tenant's recycle bin.
Fetches the site collections which are listed in your tenant's recycle bin.

## EXAMPLES

Expand All @@ -33,23 +33,30 @@ Fetches the site collection's which are listed in your tenant's recycle bin.
Get-PnPTenantDeletedSite
```

This will fetch the site collections from the recycle bin.
This will fetch basic information on site collections located in the recycle bin.

### EXAMPLE 2
```powershell
Get-PnPTenantDeletedSite -Identity "https://tenant.sharepoint.com/sites/contoso"
Get-PnPTenantDeletedSite -Detailed
```

This will fetch the site collection with the url 'https://tenant.sharepoint.com/sites/contoso' from the recycle bin and display its properties.
This will fetch detailed information on site collections located in the recycle bin.

### EXAMPLE 3
```powershell
Get-PnPTenantDeletedSite -Identity "https://tenant.sharepoint.com/sites/contoso"
```

This will fetch basic information on the site collection with the url 'https://tenant.sharepoint.com/sites/contoso' from the recycle bin.

### EXAMPLE 4
```powershell
Get-PnPTenantDeletedSite -IncludePersonalSite
```

This will fetch the site collections from the recycle bin including the personal sites and display its properties.

### EXAMPLE 4
### EXAMPLE 5
```powershell
Get-PnPTenantDeletedSite -IncludeOnlyPersonalSite
```
Expand All @@ -72,8 +79,8 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -Limit
Limit of the number of site collections to be retrieved from the recycle bin. Default is 200.
### -Detailed
When specified, detailed information will be returned on the site collections. This will take longer to execute.

```yaml
Type: SwitchParameter
Expand All @@ -86,12 +93,26 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -IncludePersonalSite
If specified the task will also retrieve the personal sites from the recycle bin.
### -Identity
Specifies the full URL of the site collection that needs to be restored.

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

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

### -IncludeOnlyPersonalSite
If specified the task will only retrieve the personal sites from the recycle bin.

```yaml
Type: SwitchParameter
Parameter Sets: (All, ParameterSetAllSites)
Parameter Sets: (ParameterSetPersonalSitesOnly)

Required: False
Position: Named
Expand All @@ -100,12 +121,12 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -IncludeOnlyPersonalSite
If specified the task will only retrieve the personal sites from the recycle bin.
### -IncludePersonalSite
If specified the task will also retrieve the personal sites from the recycle bin.

```yaml
Type: SwitchParameter
Parameter Sets: (All, ParameterSetPersonalSitesOnly)
Parameter Sets: (ParameterSetAllSites)

Required: False
Position: Named
Expand All @@ -114,21 +135,20 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -Identity
Specifies the full URL of the site collection that needs to be restored.
### -Limit
Limit of the number of site collections to be retrieved from the recycle bin. Default is 200.

```yaml
Type: String
Type: SwitchParameter
Parameter Sets: (All)

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

## RELATED LINKS

[Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp)

[Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp)
17 changes: 12 additions & 5 deletions src/Commands/Admin/GetTenantDeletedSite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,26 @@ namespace PnP.PowerShell.Commands.Admin
[Cmdlet(VerbsCommon.Get, "PnPTenantDeletedSite")]
public class GetTenantDeletedSite : PnPAdminCmdlet
{
private const string ParameterSet_ALLSITES = "ParameterSetAllSites";
private const string ParameterSet_PERSONALSITESONLY = "ParameterSetPersonalSitesOnly";

[Parameter(Position = 0, ValueFromPipeline = true, Mandatory = false)]
[Alias("Url")]
public SPOSitePipeBind Identity { get; set; }

[Parameter(Mandatory = false)]
public uint Limit = 200;

[Parameter(ParameterSetName = "ParameterSetAllSites")]
[Parameter(ParameterSetName = ParameterSet_ALLSITES)]
public SwitchParameter IncludePersonalSite { get; set; }

[Parameter(ParameterSetName = "ParameterSetPersonalSitesOnly", Mandatory = true)]
[Parameter(ParameterSetName = ParameterSet_PERSONALSITESONLY, Mandatory = true)]
public SwitchParameter IncludeOnlyPersonalSite { get; set; }

[Parameter(ParameterSetName = ParameterSet_ALLSITES)]
[Parameter(ParameterSetName = ParameterSet_PERSONALSITESONLY)]
public SwitchParameter Detailed { get; set; }

protected override void ExecuteCmdlet()
{
bool flag = Identity != null && !string.IsNullOrEmpty(Identity.Url) && UrlUtilities.IsPersonalSiteUrl(Identity.Url);
Expand Down Expand Up @@ -52,7 +59,7 @@ protected override void ExecuteCmdlet()
}
foreach (DeletedSiteProperties item in list)
{
WriteObject(new Model.SPODeletedSite(item));
WriteObject(new Model.SPODeletedSite(item, Detailed.ToBool(), AdminContext, this));
}
if (!flag2 && flag3)
{
Expand All @@ -67,9 +74,9 @@ protected override void ExecuteCmdlet()
try
{
AdminContext.ExecuteQueryRetry();
WriteObject(new Model.SPODeletedSite(deletedSitePropertiesByUrl));
WriteObject(new Model.SPODeletedSite(deletedSitePropertiesByUrl, Detailed.ToBool(), AdminContext, this));
}
catch (Microsoft.SharePoint.Client.ServerException e) when (e.ServerErrorTypeName.Equals("Microsoft.SharePoint.Client.UnknownError", StringComparison.InvariantCultureIgnoreCase))
catch (ServerException e) when (e.ServerErrorTypeName.Equals("Microsoft.SharePoint.Client.UnknownError", StringComparison.InvariantCultureIgnoreCase))
{
WriteVerbose($"No sitecollection found in the tenant recycle bin with the Url {Identity.Url}");
}
Expand Down
Loading