-
Notifications
You must be signed in to change notification settings - Fork 348
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 #3864 from reshmee011/unlocksensitivitylabelencryp…
…tedfile New cmdlet for Unlock-PnPSensitivitylabelencryptedfile
- Loading branch information
Showing
3 changed files
with
107 additions
and
0 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
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,84 @@ | ||
--- | ||
Module Name: PnP.PowerShell | ||
title: Unlock-PnPSensitivityLabelEncryptedFile | ||
schema: 2.0.0 | ||
applicable: SharePoint Online | ||
external help file: PnP.PowerShell.dll-Help.xml | ||
online version: https://pnp.github.io/powershell/cmdlets/Unlock-PnPSensitivityLabelEncryptedFile.html | ||
--- | ||
|
||
# Unlock-PnPSensitivityLabelEncryptedFile | ||
|
||
## SYNOPSIS | ||
|
||
**Required Permissions** | ||
|
||
* SharePoint: Access to the SharePoint Tenant Administration site | ||
|
||
## SYNTAX | ||
|
||
```powershell | ||
Unlock-PnPSensitivityLabelEncryptedFile -Url <String> -JustificationText <string> [-Connection <PnPConnection>] | ||
``` | ||
|
||
## DESCRIPTION | ||
|
||
It removes encryption on a Sensitivity label encrypted file in SharePoint Online. | ||
|
||
## EXAMPLES | ||
|
||
### EXAMPLE 1 | ||
```powershell | ||
Unlock-PnPSensitivityLabelEncryptedFile -Url "https://contoso.com/sites/Marketing/Shared Documents/Doc1.docx" -JustificationText "Need to access file" | ||
``` | ||
|
||
This example will remove a regular label with admin defined encryption from the file Doc1.docx and also make an entry in audit logs. | ||
|
||
## 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 | ||
``` | ||
### -Url | ||
Full URL for the file | ||
```yaml | ||
Type: string. | ||
Parameter Sets: (All) | ||
|
||
Required: True | ||
Position: Named | ||
Default value: None | ||
Accept pipeline input: False | ||
Accept wildcard characters: False | ||
``` | ||
### -JustificationText | ||
Text that explains the reason to run this cmdlet on the given file. | ||
```yaml | ||
Type: string. | ||
Parameter Sets: (All) | ||
|
||
Required: True | ||
Position: Named | ||
Default value: None | ||
Accept pipeline input: False | ||
Accept wildcard characters: False | ||
``` | ||
## RELATED LINKS | ||
[Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp) | ||
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,22 @@ | ||
using PnP.PowerShell.Commands.Base; | ||
using System.Management.Automation; | ||
|
||
namespace PnP.PowerShell.Commands.Files | ||
{ | ||
[Cmdlet(VerbsCommon.Unlock, "PnPSensitivityLabelEncryptedFile")] | ||
public class UnlockSensitivityLabelEncryptedFile : PnPAdminCmdlet | ||
{ | ||
[Parameter(Mandatory = true, Position = 0, ValueFromPipeline = true)] | ||
public string Url = string.Empty; | ||
[Parameter(Mandatory = true)] | ||
public string JustificationText = string.Empty; | ||
protected override void ExecuteCmdlet() | ||
{ | ||
// Remove URL decoding from the Url as that will not work. We will encode the + character specifically, because if that is part of the filename, it needs to stay and not be decoded. | ||
Url = Utilities.UrlUtilities.UrlDecode(Url.Replace("+", "%2B")); | ||
|
||
Tenant.UnlockSensitivityLabelEncryptedFile(Url, JustificationText); | ||
AdminContext.ExecuteQuery(); | ||
} | ||
} | ||
} |