-
Notifications
You must be signed in to change notification settings - Fork 327
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added
Get-PnPSensitivityLabel
(#2023)
* Added Get-PnPSensitivityLabel * Added PR reference * Adding documentation to model Co-authored-by: = <=>
- Loading branch information
1 parent
a7fd695
commit d8cb5d1
Showing
8 changed files
with
224 additions
and
4 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,94 @@ | ||
--- | ||
Module Name: PnP.PowerShell | ||
schema: 2.0.0 | ||
applicable: SharePoint Online | ||
online version: https://pnp.github.io/powershell/cmdlets/Get-PnPSensitivityLabel.html | ||
external help file: PnP.PowerShell.dll-Help.xml | ||
title: Get-PnPSensitivityLabel | ||
--- | ||
|
||
# Get-PnPSensitivityLabel | ||
|
||
## SYNOPSIS | ||
Gets the Microsoft Purview sensitivity labels that are available within the tenant | ||
|
||
## SYNTAX | ||
|
||
```powershell | ||
Get-PnPSensitivityLabel [-Identity <Guid>] [-User <AzureADUserPipeBind>] [-Connection <PnPConnection>] [<CommonParameters>] | ||
``` | ||
|
||
## DESCRIPTION | ||
This cmdlet allows retrieval of the available Microsoft Purview sensitivity labels in the currently connected tenant. You can retrieve all the labels, a specific label or all the labels available to a specific user. | ||
|
||
## EXAMPLES | ||
|
||
### EXAMPLE 1 | ||
```powershell | ||
Get-PnPSensitivityLabel | ||
``` | ||
|
||
Returns all the Microsoft Purview sensitivitiy labels that exist on the tenant | ||
|
||
### EXAMPLE 2 | ||
```powershell | ||
Get-PnPSensitivityLabel -User johndoe@tenant.onmicrosoft.com | ||
``` | ||
|
||
Returns all Microsoft Purview sensitivitiy labels which are available to the provided user | ||
|
||
### EXAMPLE 3 | ||
```powershell | ||
Get-PnPSensitivityLabel -Identity 47e66706-8627-4979-89f1-fa7afeba2884 | ||
``` | ||
|
||
Returns a specific Microsoft Purview sensitivitiy label by its id | ||
|
||
## PARAMETERS | ||
|
||
### -Identity | ||
The Id of the Microsoft Purview sensitivity label to retrieve | ||
|
||
```yaml | ||
Type: Guid | ||
Parameter Sets: (All) | ||
|
||
Required: False | ||
Position: Named | ||
Default value: None | ||
Accept pipeline input: False | ||
Accept wildcard characters: False | ||
``` | ||
|
||
### -User | ||
The UPN, Id or instance of an Azure AD user for which you would like to retrieve the Microsoft Purview sensitivity labels available to this user | ||
|
||
```yaml | ||
Type: SwitchParameter | ||
Parameter Sets: (All) | ||
|
||
Required: False | ||
Position: Named | ||
Default value: None | ||
Accept pipeline input: False | ||
Accept wildcard characters: False | ||
``` | ||
|
||
### -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 | ||
``` | ||
|
||
## RELATED LINKS | ||
|
||
[Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp) | ||
[Microsoft Graph documentation](https://docs.microsoft.com/graph/api/informationprotectionpolicy-list-labels) |
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
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
59 changes: 59 additions & 0 deletions
59
src/Commands/Model/Graph/Purview/InformationProtectionLabel.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,59 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace PnP.PowerShell.Commands.Model.Graph.Purview | ||
{ | ||
/// <summary> | ||
/// Describes the information protection label that details how to properly apply a sensitivity label to information. The informationProtectionLabel resource describes the configuration of sensitivity labels that apply to a user or tenant. | ||
/// </summary> | ||
/// <seealso cref="https://docs.microsoft.com/graph/api/resources/informationprotectionlabel"/> | ||
public class InformationProtectionLabel | ||
{ | ||
/// <summary> | ||
/// The label ID is a globally unique identifier (GUID) | ||
/// </summary> | ||
[JsonPropertyName("id")] | ||
public string Id { get; set; } | ||
|
||
/// <summary> | ||
/// The plaintext name of the label. | ||
/// </summary> | ||
[JsonPropertyName("name")] | ||
public string Name { get; set; } | ||
|
||
/// <summary> | ||
/// The admin-defined description for the label. | ||
/// </summary> | ||
[JsonPropertyName("description")] | ||
public string Description { get; set; } | ||
|
||
/// <summary> | ||
/// The color that the UI should display for the label, if configured. | ||
/// </summary> | ||
[JsonPropertyName("color")] | ||
public string Color { get; set; } | ||
|
||
/// <summary> | ||
/// The sensitivity value of the label, where lower is less sensitive. | ||
/// </summary> | ||
[JsonPropertyName("sensitivity")] | ||
public int Sensitivity { get; set; } | ||
|
||
/// <summary> | ||
/// The tooltip that should be displayed for the label in a UI. | ||
/// </summary> | ||
[JsonPropertyName("tooltip")] | ||
public string Tooltip { get; set; } | ||
|
||
/// <summary> | ||
/// Indicates whether the label is active or not. Active labels should be hidden or disabled in UI. | ||
/// </summary> | ||
[JsonPropertyName("isActive")] | ||
public bool? IsActive { get; set; } | ||
|
||
/// <summary> | ||
/// The parent label associated with a child label. Null if label has no parent. | ||
/// </summary> | ||
[JsonPropertyName("parent")] | ||
public object Parent { get; set; } | ||
} | ||
} |
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,57 @@ | ||
using PnP.PowerShell.Commands.Attributes; | ||
using PnP.PowerShell.Commands.Base; | ||
using PnP.PowerShell.Commands.Base.PipeBinds; | ||
using PnP.PowerShell.Commands.Utilities.REST; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Management.Automation; | ||
|
||
namespace PnP.PowerShell.Commands.PowerPlatform.PowerAutomate | ||
{ | ||
[Cmdlet(VerbsCommon.Get, "PnPSensitivityLabel")] | ||
[RequiredMinimalApiPermissions("InformationProtectionPolicy.Read.All")] | ||
[OutputType(typeof(IEnumerable<Model.Graph.Purview.InformationProtectionLabel>))] | ||
[OutputType(typeof(Model.Graph.Purview.InformationProtectionLabel))] | ||
public class GetSensitivityLabel : PnPGraphCmdlet | ||
{ | ||
[Parameter(Mandatory = false)] | ||
public AzureADUserPipeBind User; | ||
|
||
[Parameter(Mandatory = false)] | ||
public Guid Identity; | ||
|
||
protected override void ExecuteCmdlet() | ||
{ | ||
string url; | ||
if (ParameterSpecified(nameof(User))) | ||
{ | ||
var user = User.GetUser(AccessToken); | ||
|
||
if(user == null) | ||
{ | ||
WriteWarning("Provided user not found"); | ||
return; | ||
} | ||
|
||
url = $"/beta/users/{user.UserPrincipalName}/informationProtection/policy/labels"; | ||
} | ||
else | ||
{ | ||
url = "/beta/informationProtection/policy/labels"; | ||
} | ||
|
||
if (ParameterSpecified(nameof(Identity))) | ||
{ | ||
url += $"/{Identity}"; | ||
|
||
var labels = GraphHelper.GetAsync<Model.Graph.Purview.InformationProtectionLabel>(Connection, url, AccessToken).GetAwaiter().GetResult(); | ||
WriteObject(labels, false); | ||
} | ||
else | ||
{ | ||
var labels = GraphHelper.GetResultCollectionAsync<Model.Graph.Purview.InformationProtectionLabel>(Connection, url, AccessToken).GetAwaiter().GetResult(); | ||
WriteObject(labels, 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