Skip to content

Latest commit

 

History

History
144 lines (109 loc) · 4.28 KB

Move-PnPFile.md

File metadata and controls

144 lines (109 loc) · 4.28 KB
external help file applicable schema
SharePoint Server 2013, SharePoint Server 2016, SharePoint Online
2.0.0

Move-PnPFile

SYNOPSIS

Moves a file to a different location

SYNTAX

Server Relative

Move-PnPFile -ServerRelativeUrl <String>
             -TargetUrl <String>
             [-OverwriteIfAlreadyExists [<SwitchParameter>]]
             [-Force [<SwitchParameter>]]
             [-Web <WebPipeBind>]
             [-Connection <SPOnlineConnection>]

Site Relative

Move-PnPFile -SiteRelativeUrl <String>
             -TargetUrl <String>
             [-OverwriteIfAlreadyExists [<SwitchParameter>]]
             [-Force [<SwitchParameter>]]
             [-Web <WebPipeBind>]
             [-Connection <SPOnlineConnection>]

EXAMPLES

------------------EXAMPLE 1------------------

PS:>Move-PnPFile -ServerRelativeUrl /sites/project/Documents/company.docx -TargetUrl /sites/otherproject/Documents/company.docx

Moves a file named company.docx located in the document library called Documents located in the projects sitecollection under the managed path sites to the site collection otherproject located in the managed path sites. If a file named company.aspx already exists, it won't perform the move.

------------------EXAMPLE 2------------------

PS:>Move-PnPFile -SiteRelativeUrl Documents/company.aspx -TargetUrl /sites/otherproject/Documents/company.docx

Moves a file named company.docx located in the document library called Documents located in the current site to the Documents library in the site collection otherproject located in the managed path sites. If a file named company.aspx already exists, it won't perform the move.

------------------EXAMPLE 3------------------

PS:>Move-PnPFile -ServerRelativeUrl /sites/project/Documents/company.docx -TargetUrl /sites/otherproject/Documents/company.docx -OverwriteIfAlreadyExists

Moves a file named company.docx located in the document library called Documents located in the projects sitecollection under the managed path sites to the site collection otherproject located in the managed path sites. If a file named company.aspx already exists, it will still perform the move and replace the original company.aspx file.

PARAMETERS

-Force

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

Type: SwitchParameter
Parameter Sets: (All)

Required: False
Position: Named
Accept pipeline input: False

-OverwriteIfAlreadyExists

If provided, if a file already exists at the TargetUrl, it will be overwritten. If ommitted, the move operation will be canceled if the file already exists at the TargetUrl location.

Type: SwitchParameter
Parameter Sets: (All)

Required: False
Position: Named
Accept pipeline input: False

-ServerRelativeUrl

Server relative Url specifying the file to move. Must include the file name.

Type: String
Parameter Sets: Server Relative

Required: True
Position: 0
Accept pipeline input: True

-SiteRelativeUrl

Site relative Url specifying the file to move. Must include the file name.

Type: String
Parameter Sets: Site Relative

Required: True
Position: 0
Accept pipeline input: True

-TargetUrl

Server relative Url where to move the file to. Must include the file name.

Type: String
Parameter Sets: (All)

Required: True
Position: 1
Accept pipeline input: False

-Connection

Optional connection to be used by cmdlet. Retrieve the value for this parameter by eiter specifying -ReturnConnection on Connect-PnPOnline or by executing Get-PnPConnection.

Type: SPOnlineConnection
Parameter Sets: (All)

Required: False
Position: Named
Accept pipeline input: False

-Web

This parameter allows you to optionally apply the cmdlet action to a subweb within the current web. In most situations this parameter is not required and you can connect to the subweb using Connect-PnPOnline instead. Specify the GUID, server relative url (i.e. /sites/team1) or web instance of the web to apply the command to. Omit this parameter to use the current web.

Type: WebPipeBind
Parameter Sets: (All)

Required: False
Position: Named
Accept pipeline input: False

RELATED LINKS

SharePoint Developer Patterns and Practices