Skip to content

Commit

Permalink
added an ability to log verbosely
Browse files Browse the repository at this point in the history
  • Loading branch information
Zerg00s committed May 20, 2022
1 parent bae7273 commit a68bc8c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 11 deletions.
2 changes: 1 addition & 1 deletion MISC/PS-Forms.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 13 additions & 8 deletions Move-Lists.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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(",")
}
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Start-Process $Url_To_Open
17 changes: 15 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
```
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit a68bc8c

Please sign in to comment.