-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathMove-SPList.ps1
66 lines (54 loc) · 1.7 KB
/
Move-SPList.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<#
$Metadata = @{
Title = "Move SharePoint list"
Filename = "Move-SPList.ps1"
Description = ""
Tags = "powershell, function, sharepoint"
Project = ""
Author = "Janik von Rotz"
AuthorContact = "http://www.janikvonrotz.ch"
CreateDate = "2013-10-10"
LastEditDate = "2013-11-19"
Version = "1.1.0"
License = @'
This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.
To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/3.0/ or
send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.
'@
}
#>
function Move-SPList{
<#
.DESCRIPTION
Move a SharePoint list
.PARAMETER ListUrl
Source Url of the List.
.PARAMETER WebUrl
Destination Url of the Website.
.PARAMETER NoFileCompression
Provide this parameter if the compressed list is oversized.
.EXAMPLE
Move-SP-List
#>
param(
[Parameter(Mandatory=$true)]
[String]
$ListUrl,
[Parameter(Mandatory=$true)]
[String]
$WebUrl,
[Switch]
$NoFileCompression
)
#--------------------------------------------------#
# modules
#--------------------------------------------------#
if(-not (Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue)){Add-PSSnapin "Microsoft.SharePoint.PowerShell"}
#--------------------------------------------------#
# main
#--------------------------------------------------#
$Path = (Export-SPList -ListUrl $ListUrl -NoFileCompression:$NoFileCompression)
Import-SPList -WebUrl $WebUrl -Path $Path -NoFileCompression:$NoFileCompression
Write-Host "Remove item $Path"
Remove-Item -Path $Path -Force -confirm:$false -Recurse
}