Table of Contents

Remove-PnPFileSharingLink

SYNOPSIS

Removes sharing links associated with a file.

SYNTAX

Remove-PnPFileSharingLink -FileUrl <String> -Identity <String> -Force <SwitchParamter> [-Connection <PnPConnection>] 

DESCRIPTION

Removes sharing links associated with a file.

EXAMPLES

EXAMPLE 1

Remove-PnPFileSharingLink -FileUrl "/sites/demo/Shared Documents/Test.docx"

This will delete all the sharing links associated with the Test.docx file in the Shared Documents document library.

EXAMPLE 2

Remove-PnPFileSharingLink -FileUrl "/sites/demo/Shared Documents/Test.docx" -Force

This will delete all the sharing links associated with the Test.docx file in the Shared Documents document library. User will not be prompted for confirmation.

EXAMPLE 3

$sharingLinks = Get-PnPFileSharingLink -FileUrl "/sites/demo/Shared Documents/Test.docx"
Remove-PnPFileSharingLink -FileUrl "/sites/demo/Shared Documents/Test.docx" -Identity $sharingLinks[0].Id -Force

This will delete the first sharing link associated with the Test.docx file in the Shared Documents document library. User will not be prompted for confirmation.

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.

Type: PnPConnection
Parameter Sets: (All)

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-FileUrl

The file in the site

Type: String
Parameter Sets: (All)

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Identity

The Id of the sharing link associated with the file. You can retrieve the identity using Get-PnPFileSharingLink cmdlet.

Type: Identity
Parameter Sets: (All)

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Force

If provided, no confirmation will be requested and the action will be performed

Type: String
Parameter Sets: (All)

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

Microsoft 365 Patterns and Practices