Skip to content

Commit

Permalink
Commit from GitHub Actions (Build Documentation Site)
Browse files Browse the repository at this point in the history
  • Loading branch information
erwinvanhunen committed Apr 10, 2024
1 parent 1767cfd commit 08280e0
Show file tree
Hide file tree
Showing 3 changed files with 174 additions and 5 deletions.
171 changes: 170 additions & 1 deletion cmdlets/Copy-PnPFolder.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,176 @@
<h1 id="copy-pnpfolder">Copy-PnPFolder</h1>

<h2 id="synopsis">SYNOPSIS</h2>
<p>This is an alias for <a href="Copy-PnPFile.html">Copy-PnPFile</a>.</p>
<p>Copies a folder or file to a different location within SharePoint Online or allows uploading of an entire local folder with optionally subfolders to SharePoint Online.</p>
<h2 id="syntax">SYNTAX</h2>
<h3 id="copy-files-within-microsoft-365">Copy files within Microsoft 365</h3>
<pre><code class="lang-powershell">Copy-PnPFolder -SourceUrl &lt;String&gt; -TargetUrl &lt;String&gt; [-Overwrite] [-Force] [-IgnoreVersionHistory] [-NoWait] [-Connection &lt;PnPConnection&gt;] [-Verbose]

</code></pre>
<h3 id="copy-files-from-local-to-microsoft-365">Copy files from local to Microsoft 365</h3>
<pre><code class="lang-powershell">Copy-PnPFolder -LocalPath &lt;String&gt; -TargetUrl &lt;String&gt; [-Overwrite] [-Recurse] [-RemoveAfterCopy] [-Connection &lt;PnPConnection&gt;] [-Verbose]

</code></pre>
<h2 id="description">DESCRIPTION</h2>
<p>Copies a folder or file to a different location within SharePoiint. This location can be within the same document library, same site, same site collection or even to another site collection on the same tenant. Notice that if copying between sites or to a subsite you cannot specify a target filename, only a folder name.</p>
<p>Copying files and folders is bound to some restrictions. You can find more on it here: <a href="https://learn.microsoft.com/office365/servicedescriptions/sharepoint-online-service-description/sharepoint-online-limits#moving-and-copying-across-sites">https://learn.microsoft.com/office365/servicedescriptions/sharepoint-online-service-description/sharepoint-online-limits#moving-and-copying-across-sites</a></p>
<p>It can also accommodate copying an entire folder with all its files and optionally even subfolders and files from a local path onto SharePoint Online.</p>
<h2 id="examples">EXAMPLES</h2>
<h3 id="example-1">EXAMPLE 1</h3>
<pre><code class="lang-powershell">Copy-PnPFolder -SourceUrl &quot;Shared Documents/MyProjectfiles&quot; -TargetUrl &quot;/sites/otherproject/Shared Documents&quot; -Overwrite
</code></pre>
<p>Copies a folder named MyProjectFiles in the document library called Documents located in the current site to the root folder of the library named Documents in the site collection otherproject. If a folder named MyProjectFiles already exists, it will overwrite it.</p>
<h3 id="example-2">EXAMPLE 2</h3>
<pre><code class="lang-powershell">Copy-PnPFolder -SourceUrl &quot;/sites/project/Shared Documents/company.docx&quot; -TargetUrl &quot;/sites/otherproject/Shared Documents&quot;
</code></pre>
<p>Copies a file named company.docx located in a document library called Shared Documents in the site collection project to the Shared Documents library in the site collection otherproject. If a file named company.docx already exists, it won't perform the copy.</p>
<h3 id="example-3">EXAMPLE 3</h3>
<pre><code class="lang-powershell">Copy-PnPFolder -SourceUrl &quot;Shared Documents/company.docx&quot; -TargetUrl &quot;/sites/otherproject/Shared Documents&quot; -IgnoreVersionHistory
</code></pre>
<p>Copies a file named company.docx located in a document library called Documents in the current site to the site collection otherproject. If a file named company.docx already exists, it won't perform the copy. Only the latest version of the file will be copied and its history will be discarded.</p>
<h3 id="example-4">EXAMPLE 4</h3>
<pre><code class="lang-powershell">Copy-PnPFolder -SourceUrl &quot;/sites/project/Shared Documents/Archive&quot; -TargetUrl &quot;/sites/otherproject/Shared Documents&quot; -Overwrite
</code></pre>
<p>Copies a folder named Archive located in a document library called Shared Documents in the site collection project to the Shared Documents library in the site collection otherproject. If a folder named Archive already exists, it will overwrite it.</p>
<h3 id="example-5">EXAMPLE 5</h3>
<pre><code class="lang-powershell">Copy-PnPFolder -SourceUrl &quot;Documents/company.docx&quot; -TargetUrl &quot;Documents/company2.docx&quot;
</code></pre>
<p>Copies a file named company.docx located in a document library called Documents to a new document named company2.docx in the same library.</p>
<h3 id="example-6">EXAMPLE 6</h3>
<pre><code class="lang-powershell">Copy-PnPFolder -SourceUrl &quot;Shared Documents/company.docx&quot; -TargetUrl &quot;Shared Documents2/company.docx&quot;
</code></pre>
<p>Copies a file named company.docx located in a document library called Documents to a document library called Documents2 in the same site.</p>
<h3 id="example-7">EXAMPLE 7</h3>
<pre><code class="lang-powershell">Copy-PnPFolder -SourceUrl &quot;Shared DocuDocuments/company.docx&quot; -TargetUrl &quot;Subsite/Shared Documents&quot;
</code></pre>
<p>Copies a file named company.docx located in a document library called Documents to the document library named Documents in a subsite named Subsite keeping the file name.</p>
<h3 id="example-8">EXAMPLE 8</h3>
<pre><code class="lang-powershell">Copy-PnPFolder -SourceUrl &quot;Shared Documents/company.docx&quot; -TargetUrl &quot;/sites/otherproject/Shared Documents&quot; -Overwrite
</code></pre>
<p>Copies a file named company.docx located in a document library called Documents in the current site to the site collection otherproject. If a file named company.docx already exists, it will still perform the copy and replace the original company.docx file.</p>
<h3 id="example-9">EXAMPLE 9</h3>
<pre><code class="lang-powershell">Copy-PnPFolder -SourceUrl &quot;Shared Documents/MyDocs&quot; -TargetUrl &quot;/sites/otherproject/Documents&quot; -Overwrite
</code></pre>
<p>Copies a folder named MyDocs in the document library called Documents located in the current site to the site collection otherproject. If the MyDocs folder exist it will copy into it, if not it will be created.</p>
<h3 id="example-10">EXAMPLE 10</h3>
<pre><code class="lang-powershell">Copy-PnPFolder -SourceUrl &quot;SubSite1/Documents/company.docx&quot; -TargetUrl &quot;SubSite2/Documents&quot;
</code></pre>
<p>Copies a file named company.docx in the library named Documents in SubSite1 to the library named Documents in SubSite2.</p>
<h3 id="example-11">EXAMPLE 11</h3>
<pre><code class="lang-powershell">$job = Copy-PnPFolder -SourceUrl &quot;Shared Documents/company.docx&quot; -TargetUrl &quot;SubSite2/Shared Documents&quot; -NoWait
$jobStatus = Receive-PnPCopyMoveJobStatus -Job $result
if($jobStatus.JobState == 0)
{
Write-Host &quot;Job finished&quot;
}
</code></pre>
<p>Copies a file named company.docx from the current document library to the documents library in SubSite2. It will not wait for the action to return but returns job information instead. The Receive-PnPCopyMoveJobStatus cmdlet will return the job status.</p>
<h3 id="example-12">EXAMPLE 12</h3>
<pre><code class="lang-powershell">Copy-PnPFolder -LocalPath &quot;c:\temp&quot; -TargetUrl &quot;Subsite1/Shared Documents&quot; -Recurse -Overwrite
</code></pre>
<p>Copies all the files and underlying folders from the local folder c:\temp to the document library Shared Documents in Subsite1. If a file already exists, it will be overwritten.</p>
<h2 id="parameters">PARAMETERS</h2>
<h3 id="-force">-Force</h3>
<p>If provided, no confirmation will be requested and the action will be performed</p>
<pre><code class="lang-yaml">Type: SwitchParameter
Parameter Sets: WITHINM365

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
</code></pre>
<h3 id="-ignoreversionhistory">-IgnoreVersionHistory</h3>
<p>If provided, only the latest version of the document will be copied and its history will be discarded. If not provided, all historical versions will be copied.</p>
<pre><code class="lang-yaml">Type: SwitchParameter
Parameter Sets: WITHINM365

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
</code></pre>
<h3 id="-overwrite">-Overwrite</h3>
<p>If provided, if a file already exists at the TargetUrl, it will be overwritten. If omitted, the copy operation will be canceled if the file already exists at the TargetUrl location when copying between two locations on SharePoint Online. If copying files from a local path to SharePoint Online, it will skip any file that already exists and still continue with the next one.</p>
<pre><code class="lang-yaml">Type: SwitchParameter
Parameter Sets: (All)

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
</code></pre>
<h3 id="-sourceurl">-SourceUrl</h3>
<p>Site or server relative URL specifying the file or folder to copy. Must include the file name if it is a file or the entire path to the folder if it is a folder.</p>
<pre><code class="lang-yaml">Type: String
Parameter Sets: WITHINM365
Aliases: SiteRelativeUrl, ServerRelativeUrl

Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
</code></pre>
<h3 id="-targeturl">-TargetUrl</h3>
<p>Site or server relative URL where to copy the file or folder to. Must not include the file name.</p>
<pre><code class="lang-yaml">Type: String
Parameter Sets: (All)
Aliases: TargetServerRelativeLibrary

Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
</code></pre>
<h3 id="-nowait">-NoWait</h3>
<p>If specified the task will return immediately after creating the copy job. The cmdlet will return a job object which can be used with Receive-PnPCopyMoveJobStatus to retrieve the status of the job.</p>
<pre><code class="lang-yaml">Type: SwitchParameter
Parameter Sets: WITHINM365

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
</code></pre>
<h3 id="-recurse">-Recurse</h3>
<p>When copying files from a local folder to SharePoint Online, this parameter will copy all files and folders within the local folder and all of its subfolders as well.</p>
<pre><code class="lang-yaml">Type: SwitchParameter
Parameter Sets: FROMLOCAL

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
</code></pre>
<h3 id="-removeaftercopy">-RemoveAfterCopy</h3>
<p>When copying files from a local folder to SharePoint Online, this parameter will remove all files locally that have successfully been uploaded to SharePoint Online. If a file fails, it will not be removed locally. Local folders will be removed after all files have been uploaded and the folder is empty.</p>
<pre><code class="lang-yaml">Type: SwitchParameter
Parameter Sets: FROMLOCAL

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
</code></pre>
<h3 id="-verbose">-Verbose</h3>
<p>When provided, additional debug statements will be shown while executing the cmdlet.</p>
<pre><code class="lang-yaml">Type: SwitchParameter
Parameter Sets: (All)

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
</code></pre>
<h2 id="related-links">RELATED LINKS</h2>
<p><a href="https://aka.ms/m365pnp">Microsoft 365 Patterns and Practices</a></p>

Expand Down
4 changes: 2 additions & 2 deletions cmdlets/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
</div>
<h1 id="pnp-powershell-cmdlets">PnP PowerShell cmdlets</h1>

<p>PnP PowerShell exists out of 707 cmdlets which can help you in setting up, configuring, maintaining and using various Microsoft 365 products from one single connection. Each of the cmdlets is documented to aid in learning how to use it. Find the available cmdlets below.</p>
<p>PnP PowerShell exists out of 708 cmdlets which can help you in setting up, configuring, maintaining and using various Microsoft 365 products from one single connection. Each of the cmdlets is documented to aid in learning how to use it. Find the available cmdlets below.</p>
<p><sup>1</sup>: Only available in the latest nightly build. All the others can also be used using the latest stable release.<br>
<sup>2</sup>: Cmdlet is an alias of another cmdlet, used to provide backwards compatibility.</p>
<h2 id="add">Add</h2>
Expand Down Expand Up @@ -221,7 +221,7 @@ <h2 id="convertto">ConvertTo</h2>
<h2 id="copy">Copy</h2>
<ul>
<li><a href="Copy-PnPFile.html">Copy-PnPFile</a></li>
<li><a href="Copy-PnPFolder.html">Copy-PnPFolder</a> <sup>2</sup></li>
<li><a href="Copy-PnPFolder.html">Copy-PnPFolder</a></li>
<li><a href="Copy-PnPItemProxy.html">Copy-PnPItemProxy</a></li>
<li><a href="Copy-PnPList.html">Copy-PnPList</a></li>
<li><a href="Copy-PnPTeamsTeam.html">Copy-PnPTeamsTeam</a></li>
Expand Down
Loading

0 comments on commit 08280e0

Please sign in to comment.