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

Feature: added cmdlet to unfurl a link. #3224

Merged
merged 3 commits into from
Jun 25, 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 @@ -34,6 +34,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- Added `Add-PnPFileAnonymousSharingLink` and `Add-PnPFolderAnonymousSharingLink` cmdlets to create anonymous sharing links. [#3198](https://github.com/pnp/powershell/pull/3198)
- Added `Add-PnPFileSharingInvite` and `Add-PnPFolderSharingInvite` cmdlets to invite users to a file or a folder. [#3199](https://github.com/pnp/powershell/pull/3199)
- Added `Remove-PnPFileSharingLink` and `Remove-PnPFolderSharingLink` cmdlets to delete sharing links associated with files and folders. [#3200](https://github.com/pnp/powershell/pull/3200)
- Added `Get-PnPUnfurlLink` cmdlet to support unfurling a link to get more information about the link. [#3224](https://github.com/pnp/powershell/pull/3224)

### Fixed

Expand Down
69 changes: 69 additions & 0 deletions documentation/Get-PnPUnfurlLink.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
Module Name: PnP.PowerShell
schema: 2.0.0
applicable: SharePoint Online
online version: https://pnp.github.io/powershell/cmdlets/Get-PnPUnfurlLink.html
external help file: PnP.PowerShell.dll-Help.xml
title: Get-PnPUnfurlLink
---

# Get-PnPUnfurlLink

## SYNOPSIS
To unfurl a link for a given resource such as file, folder, list items etc.

## SYNTAX

```powershell
Get-PnPUnfurlLink -Url <String>
```

## DESCRIPTION

Creates a new organization sharing link for a file.

## EXAMPLES

### EXAMPLE 1
```powershell
Get-PnPUnfurlLink -Url "https://contoso.sharepoint.com/:u:/s/testsitecol/ERs6pDuyD95LpUSUsJxi1EIBr9FMEYVBvMcs_B7cPdNPgQ?e=ZL3DPe"
```

This will fetch the information of the resource to be unfurled.

SharePoint supports many different types of links, you have direct links to lists, libraries and files, but there's also sharing links that user's have created for resources in SharePoint. Whenever your application needs to understand more about a given link we call that unfurling. A common scenario is where you allow your users to paste a link and your application gets the needed information to present the content behind the link (e.g. when you paste a link in Teams you'll you'll see the file name, thumbnail and more)

## 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
The URL of the resource to be unfurled.
For more information, you can visit the [PnP Core SDK documentation](https://pnp.github.io/pnpcore/using-the-sdk/unfurl-intro.html)

```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)
21 changes: 21 additions & 0 deletions src/Commands/Security/GetUnfurlLink.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System.Management.Automation;

namespace PnP.PowerShell.Commands.Security
{
[Cmdlet(VerbsCommon.Get, "PnPUnfurlLink")]
public class GetUnfurlLink : PnPWebCmdlet
{
[Parameter(Mandatory = true)]
[ValidateNotNullOrEmpty]
public string Url;

protected override void ExecuteCmdlet()
{
var ctx = Connection.PnPContext;

var unfurledResource = ctx.Web.UnfurlLinkAsync(Url).GetAwaiter().GetResult();

WriteObject(unfurledResource);
}
}
}