diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b8dd1436..32a3568a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/documentation/Get-PnPUnfurlLink.md b/documentation/Get-PnPUnfurlLink.md new file mode 100644 index 000000000..3664fcd3e --- /dev/null +++ b/documentation/Get-PnPUnfurlLink.md @@ -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 +``` + +## 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) diff --git a/src/Commands/Security/GetUnfurlLink.cs b/src/Commands/Security/GetUnfurlLink.cs new file mode 100644 index 000000000..f4e6908e1 --- /dev/null +++ b/src/Commands/Security/GetUnfurlLink.cs @@ -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); + } + } +}