Skip to content

Commit 2191ceb

Browse files
authored
Merge pull request #3864 from reshmee011/unlocksensitivitylabelencryptedfile
New cmdlet for Unlock-PnPSensitivitylabelencryptedfile
2 parents ea27043 + f6ea4d7 commit 2191ceb

File tree

3 files changed

+107
-0
lines changed

3 files changed

+107
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
1919
- Added additional permissions for Graph application permission validate sets. [#3835](https://github.com/pnp/powershell/issues/3835)
2020
- Added the ability to upload entire local folders with files and optionally subfolders to SharePoint Online into 'Copy-PnPFolder' [#3850](https://github.com/pnp/powershell/pull/3850)
2121
- Added `LoopDefaultSharingLinkRole`, `DefaultShareLinkScope`, `DefaultShareLinkRole`, `LoopDefaultSharingLinkScope` and `DefaultLinkToExistingAccessReset` parameters to `Set-PnPTenant` cmdlet. [#3874](https://github.com/pnp/powershell/pull/3874)
22+
- Added `Unlock-PnPSensitivityLabelEncryptedFile` which allows the encryption to be removed from a file [#3864](https://github.com/pnp/powershell/pull/3864)
2223
- Added `Get-PnPLibraryFileVersionBatchDeleteJobStatus` and `Get-PnPSiteFileVersionBatchDeleteJobStatus` to check on the status of applying file based version expiration based on age on a library and site level [#3828](https://github.com/pnp/powershell/pull/3828)
2324

2425
### Fixed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
---
2+
Module Name: PnP.PowerShell
3+
title: Unlock-PnPSensitivityLabelEncryptedFile
4+
schema: 2.0.0
5+
applicable: SharePoint Online
6+
external help file: PnP.PowerShell.dll-Help.xml
7+
online version: https://pnp.github.io/powershell/cmdlets/Unlock-PnPSensitivityLabelEncryptedFile.html
8+
---
9+
10+
# Unlock-PnPSensitivityLabelEncryptedFile
11+
12+
## SYNOPSIS
13+
14+
**Required Permissions**
15+
16+
* SharePoint: Access to the SharePoint Tenant Administration site
17+
18+
## SYNTAX
19+
20+
```powershell
21+
Unlock-PnPSensitivityLabelEncryptedFile -Url <String> -JustificationText <string> [-Connection <PnPConnection>]
22+
```
23+
24+
## DESCRIPTION
25+
26+
It removes encryption on a Sensitivity label encrypted file in SharePoint Online.
27+
28+
## EXAMPLES
29+
30+
### EXAMPLE 1
31+
```powershell
32+
Unlock-PnPSensitivityLabelEncryptedFile -Url "https://contoso.com/sites/Marketing/Shared Documents/Doc1.docx" -JustificationText "Need to access file"
33+
```
34+
35+
This example will remove a regular label with admin defined encryption from the file Doc1.docx and also make an entry in audit logs.
36+
37+
## PARAMETERS
38+
39+
### -Connection
40+
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.
41+
42+
```yaml
43+
Type: PnPConnection
44+
Parameter Sets: (All)
45+
46+
Required: False
47+
Position: Named
48+
Default value: None
49+
Accept pipeline input: False
50+
Accept wildcard characters: False
51+
```
52+
53+
### -Url
54+
Full URL for the file
55+
56+
```yaml
57+
Type: string.
58+
Parameter Sets: (All)
59+
60+
Required: True
61+
Position: Named
62+
Default value: None
63+
Accept pipeline input: False
64+
Accept wildcard characters: False
65+
```
66+
67+
### -JustificationText
68+
Text that explains the reason to run this cmdlet on the given file.
69+
70+
```yaml
71+
Type: string.
72+
Parameter Sets: (All)
73+
74+
Required: True
75+
Position: Named
76+
Default value: None
77+
Accept pipeline input: False
78+
Accept wildcard characters: False
79+
```
80+
81+
## RELATED LINKS
82+
83+
[Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp)
84+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using PnP.PowerShell.Commands.Base;
2+
using System.Management.Automation;
3+
4+
namespace PnP.PowerShell.Commands.Files
5+
{
6+
[Cmdlet(VerbsCommon.Unlock, "PnPSensitivityLabelEncryptedFile")]
7+
public class UnlockSensitivityLabelEncryptedFile : PnPAdminCmdlet
8+
{
9+
[Parameter(Mandatory = true, Position = 0, ValueFromPipeline = true)]
10+
public string Url = string.Empty;
11+
[Parameter(Mandatory = true)]
12+
public string JustificationText = string.Empty;
13+
protected override void ExecuteCmdlet()
14+
{
15+
// 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.
16+
Url = Utilities.UrlUtilities.UrlDecode(Url.Replace("+", "%2B"));
17+
18+
Tenant.UnlockSensitivityLabelEncryptedFile(Url, JustificationText);
19+
AdminContext.ExecuteQuery();
20+
}
21+
}
22+
}

0 commit comments

Comments
 (0)