-
Notifications
You must be signed in to change notification settings - Fork 347
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2466 from koskila/feature/expiringgroups
Add new commandlet, Get-PnPExpiringMicrosoft365Groups
- Loading branch information
Showing
4 changed files
with
152 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
--- | ||
Module Name: PnP.PowerShell | ||
title: Get-PnPMicrosoft365ExpiringGroup | ||
schema: 2.0.0 | ||
applicable: SharePoint Online | ||
external help file: PnP.PowerShell.dll-Help.xml | ||
online version: https://pnp.github.io/powershell/cmdlets/Get-PnPMicrosoft365ExpiringGroup.html | ||
--- | ||
|
||
# Get-PnPMicrosoft365ExpiringGroup | ||
|
||
## SYNOPSIS | ||
|
||
**Required Permissions** | ||
|
||
* Microsoft Graph API : One of Directory.Read.All, Directory.ReadWrite.All, Group.Read.All, Group.ReadWrite.All, GroupMember.Read.All, GroupMember.ReadWrite.All | ||
|
||
Gets all expiring Microsoft 365 Groups. | ||
|
||
## SYNTAX | ||
|
||
```powershell | ||
Get-PnPMicrosoft365ExpiringGroup [-Limit <Int32>] [<CommonParameters>] | ||
``` | ||
|
||
## DESCRIPTION | ||
This command returns all expiring Microsoft 365 Groups within certain time. By default, groups expiring in the next 31 days are return (in accordance with SharePoint/OneDrive's retention period's 31-day months). | ||
|
||
## EXAMPLES | ||
|
||
### EXAMPLE 1 | ||
```powershell | ||
Get-PnPMicrosoft365ExpiringGroup | ||
``` | ||
|
||
Returns all Groups expiring within 31 days (roughly 1 month). | ||
|
||
### EXAMPLE 2 | ||
```powershell | ||
Get-PnPMicrosoft365ExpiringGroup -Limit 93 | ||
``` | ||
|
||
Returns all Microsoft 365 Groups expiring in 93 days (roughly 3 months) | ||
|
||
|
||
## PARAMETERS | ||
|
||
### -Limit | ||
|
||
Limits Groups to be returned to Groups expiring in as many days. | ||
|
||
```yaml | ||
Type: Int32 | ||
Parameter Sets: (All) | ||
|
||
Required: False | ||
Position: Named | ||
Default value: None | ||
Accept pipeline input: False | ||
Accept wildcard characters: False | ||
``` | ||
## RELATED LINKS | ||
[Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp) |
31 changes: 31 additions & 0 deletions
31
src/Commands/Microsoft365Groups/GetExpiringMicrosoft365Group.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using PnP.PowerShell.Commands.Attributes; | ||
using PnP.PowerShell.Commands.Base; | ||
using PnP.PowerShell.Commands.Base.PipeBinds; | ||
using PnP.PowerShell.Commands.Utilities; | ||
using System; | ||
using System.Linq; | ||
using System.Management.Automation; | ||
|
||
namespace PnP.PowerShell.Commands.Microsoft365Groups | ||
{ | ||
[Cmdlet(VerbsCommon.Get, "PnPMicrosoft365ExpiringGroup")] | ||
[RequiredMinimalApiPermissions("Group.Read.All")] | ||
public class GetExpiringMicrosoft365Group : PnPGraphCmdlet | ||
{ | ||
[Parameter(Mandatory = false)] | ||
public SwitchParameter IncludeSiteUrl; | ||
|
||
[Parameter(Mandatory = false)] | ||
public SwitchParameter IncludeOwners; | ||
|
||
[Parameter(Mandatory = false)] | ||
public int Limit = 31; | ||
|
||
protected override void ExecuteCmdlet() | ||
{ | ||
var expiringGroups = Microsoft365GroupsUtility.GetExpiringGroupAsync(Connection, AccessToken, Limit, IncludeSiteUrl, IncludeOwners).GetAwaiter().GetResult(); | ||
|
||
WriteObject(expiringGroups.OrderBy(p => p.DisplayName), true); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters