-
Notifications
You must be signed in to change notification settings - Fork 206
/
Copy pathNew-SPOMigrationPackage.ps1
106 lines (85 loc) · 3.98 KB
/
New-SPOMigrationPackage.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#Requires -Version 5.0
#Requires -Modules Microsoft.Online.SharePoint.PowerShell
<#
.SYNOPSIS
Create a new migration package based on source files in a local or network shared folder
.DESCRIPTION
.NOTES
This PowerShell script was developed and optimized for ScriptRunner. The use of the scripts requires ScriptRunner.
The customer or user is authorized to copy the script from the repository and use them in ScriptRunner.
The terms of use for ScriptRunner do not apply to this script. In particular, ScriptRunner Software GmbH assumes no liability for the function,
the use and the consequences of the use of this freely available script.
PowerShell is a product of Microsoft Corporation. ScriptRunner is a product of ScriptRunner Software GmbH.
© ScriptRunner Software GmbH
.COMPONENT
Requires Module Microsoft.Online.SharePoint.PowerShell
.LINK
https://github.com/scriptrunner/ActionPacks/tree/master/O365/SharePointOnline/Common
.Parameter OutputPackagePath
[sr-en] The directory location where the output package metadata files will be saved
.Parameter SourceFilesPath
[sr-en] The directory location where the source content files exist
.Parameter IgnoreHidden
[sr-en] Ignore hidden files and folders
.Parameter IncludeFileSharePermissions
[sr-en] Used to include permissions and sharing information into the generated manifest files in the package metadata
.Parameter NoAzureADLookup
[sr-en] Not lookup local user accounts in Azure Active Directory
.Parameter NoLogFile
[sr-en] Used to not create a log file
.Parameter ReplaceInvalidCharacters
[sr-en] Replace characters in file and folder names that would be invalid in SharePoint Online
.Parameter TargetDocumentLibraryPath
[sr-en] The web relative document library to use as the document library part of the base URL in the package metadata
.Parameter TargetDocumentLibrarySubFolderPath
[sr-en] Document library relative subfolder to use as the folder path part of the base URL in the package metadata
.Parameter TargetWebUrl
[sr-en] The fully qualified web URL to use as the web address part of the base URL in the package metadata
#>
param(
[Parameter(Mandatory = $true)]
[string]$OutputPackagePath,
[Parameter(Mandatory = $true)]
[string]$SourceFilesPath,
[switch]$IgnoreHidden,
[switch]$IncludeFileSharePermissions,
[switch]$NoAzureADLookup,
[switch]$NoLogFile,
[switch]$ReplaceInvalidCharacters,
[string]$TargetDocumentLibraryPath,
[string]$TargetDocumentLibrarySubFolderPath,
[string]$TargetWebUrl
)
Import-Module Microsoft.Online.SharePoint.PowerShell
try{
[hashtable]$cmdArgs = @{'ErrorAction' = 'Stop'
'OutputPackagePath' = $OutputPackagePath
'SourceFilesPath' = $SourceFilesPath
'IgnoreHidden' = $IgnoreHidden
'NoAzureADLookup' = $NoAzureADLookup
'NoLogFile' = $NoLogFile
'ReplaceInvalidCharacters' = $ReplaceInvalidCharacters
'IncludeFileSharePermissions' = $IncludeFileSharePermissions
}
if($PSBoundParameters.ContainsKey('TargetDocumentLibraryPath')){
$cmdArgs.Add('TargetDocumentLibraryPath',$TargetDocumentLibraryPath)
}
if($PSBoundParameters.ContainsKey('TargetDocumentLibrarySubFolderPath')){
$cmdArgs.Add('TargetDocumentLibrarySubFolderPath',$TargetDocumentLibrarySubFolderPath)
}
if($PSBoundParameters.ContainsKey('TargetWebUrl')){
$cmdArgs.Add('TargetWebUrl',$TargetWebUrl)
}
$result = New-SPOMigrationPackage @cmdArgs | Select-Object *
if($SRXEnv) {
$SRXEnv.ResultMessage = $result
}
else {
Write-Output $result
}
}
catch{
throw
}
finally{
}