diff --git a/MISC/PS-Forms.ps1 b/MISC/PS-Forms.ps1 index ffa17fa..457b9b6 100644 --- a/MISC/PS-Forms.ps1 +++ b/MISC/PS-Forms.ps1 @@ -603,7 +603,7 @@ function Get-FormItemProperties { $Form = New-Object System.Windows.Forms.Form - $Form.Height = 380 + $Form.Height = 480 $Form.Width = 530 $Form.Text = $dialogTitle $Form.Topmost = $true diff --git a/Move-Lists.ps1 b/Move-Lists.ps1 index 385e562..2390ca4 100644 --- a/Move-Lists.ps1 +++ b/Move-Lists.ps1 @@ -22,15 +22,20 @@ Get-ChildItem -Recurse | Unblock-File Import-Module (Get-ChildItem -Recurse -Filter "*.psd1").FullName -DisableNameChecking $Migration = @{ - Source_Site = "https://contoso.sharepoint.com/sites/Site_A" - Target_Site = "https://contoso.sharepoint.com/sites/Site_b" - Lists = "" + Source_Site = "https://contoso.sharepoint.com/sites/Site_A" + Target_Site = "https://contoso.sharepoint.com/sites/Site_b" + Lists = "" + Verbose_Logs = "FALSE" } -$Migration = Get-FormItemProperties -item $Migration -dialogTitle "Enter source and target sites" -propertiesOrder @("Source_Site", "Target_Site", "Lists") -note "List titles are comma-separated. Leave blank to have an interactive selector" +$Migration = Get-FormItemProperties -item $Migration -dialogTitle "Enter source and target sites" -propertiesOrder @("Source_Site", "Target_Site", "Lists", "Verbose_Logs") -note "List titles are comma-separated. Leave blank to have an interactive selector" Connect-PnPOnline -Url $Migration.Source_Site -UseWebLogin -WarningAction Ignore +if([System.Convert]::ToBoolean($Migration.Verbose_Logs)){ + Write-host "Verbose logging is on" -ForegroundColor Yellow + Set-PnPTraceLog -On -Level Debug +} if ($Migration.Lists) { $titles = $Migration.Lists.Split(",") } @@ -58,13 +63,13 @@ else { } if ($exportContentTypes) { - Get-pnpProvisioningTemplate -ListsToExtract $titles -Out "Lists.xml" -Handlers Lists, ContentTypes, Fields -Force -WarningAction Ignore + Get-PnPProvisioningTemplate -ListsToExtract $titles -Out "Lists.xml" -Handlers Lists, ContentTypes, Fields -Force -WarningAction Ignore } else { - Get-pnpProvisioningTemplate -ListsToExtract $titles -Out "Lists.xml" -Handlers Lists -Force -WarningAction Ignore + Get-PnPProvisioningTemplate -ListsToExtract $titles -Out "Lists.xml" -Handlers Lists -Force -WarningAction Ignore } -((Get-Content -path Lists.xml -Raw) -replace 'RootSite', 'Web') | Set-Content -Path Lists.xml +((Get-Content -Path Lists.xml -Raw) -replace 'RootSite', 'Web') | Set-Content -Path Lists.xml foreach ($title in $titles) { # Get the latest list item form layout. Footer, Header and the Body: @@ -93,4 +98,4 @@ Write-Host "" Write-Host "Target site" $($Migration.Target_Site + "/_layouts/15/viewlsts.aspx") -ForegroundColor Yellow $Url_To_Open = ($Migration.Target_Site + "/_layouts/15/viewlsts.aspx") -Start-Process $Url_To_Open \ No newline at end of file +Start-Process $Url_To_Open diff --git a/README.md b/README.md index f8ba601..db1cc16 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ Easily move SharePoint Online list templates from one site to another. ## Prerequisites +- Requires [PowerShell 5.0 or later](https://www.microsoft.com/en-us/download/details.aspx?id=54616) - Launch PowerShell - Run the following command: ``` @@ -46,18 +47,30 @@ Set-ExecutionPolicy Unrestricted -Scope CurrentUser - Sit back and watch your lists and libraries migrate. -## Windows Defender Smartscreen: +## Windows Defender Smart screen: Windows Defender will display a security warning when you attempt to run scripts downloaded from the Internet. ![](MISC/IMG/WindowsDeFender.png) -To avoid this warning: +To avoid this warning you need to unblock the script files using one of the options: + +### Option 1: unblock files manually 1. Right click on the `Move-Lists.bat` file and open the Properties window from the contextual menu. 2. At the bottom of the "General" tab, you should see a "Security" section with an "Unblock" checkbox or button. Click on the button or check the box. 3. Click OK. 4. You should now be able to execute the BAT file without warning. +### Option 2: Using PowerShell + +1. Start PowerShell +2. cd to the Move-Lists folder +3. Run the following script to unblock all script files + +``` +Get-ChildItem -Recurse | Unblock-File +``` + ## Limitations - The script is portable. There is no need to install any PowerShell modules. - Only SharePoint Online is supported.