Articles about European Sharepoint Hosting Service
Posts tagged CSS in SPFx
SharePoint 2013 Hosting – HostForLIFE.eu :: File Server Migration To SharePoint Online Using SPMT PowerShell
Dec 10th

Issue
- The documentation for this is not that accurate or in single place. We need to search here and there for things.
- SPMT tool migrates file server child items directly but when you use PowerShell, it migrates parent folder. Due to the curse of first point, it took some time for us to find the hidden solution. Go through this post to see that hidden gem.
- The last but not least is permission migration. SPMT has all this functionality but as I said earlier it is not documented well.
Solution
- Do not include a header row in your CSV file.
- Remember to account for all six columns in the file, even if you are not needing a value for a given field.
- If you use the standard out-of-the-box Document library (“Shared Documents”), you must use the Display name “Documents” as the placeholder value for the Target Document Library in your CSV file. If you enter “Shared Documents” in that column, you will receive an “invalid document library” error.
1 |
Source,SourceDocLib,SourceSubFolder,TargetWeb,TargetDocLib,TargetSubFolder |
SharePoint 2013 Hosting – HostForLIFE.eu :: How To Create a Copy Of Site Page And Update Property Of The Web Parts
Dec 3rd
How to create a copy of the page
1 2 3 4 |
export interface ICopyPageProps { description: string; context: any; } |
1 2 3 4 5 6 7 |
const element: React.ReactElement<ICopyPageProps> = React.createElement( CopyPage, { description: this.properties.description, context: this.context } ); |
Step 3
1 2 3 4 |
import { sp } from "@pnp/sp"; import "@pnp/sp/webs"; import { ClientsidePageFromFile, IClientsidePage, ClientsideWebpart } from "@pnp/sp/clientside-pages"; |
Step 4
1 |
var sourcePageURL = “https://****.sharepoint.com/sites/Test/SitePages/sourcepage.aspx”; |
Step 5
1 |
const pageTemplate = await ClientsidePageFromFile(sp.web.getFileByServerRelativePath(sourcePageURL)); |
Step 6
- web: The web where we will create the copy
- pageName: The file name of the new page
- title: The title of the new page
- publish: If true the page will be published
1 |
const newPage = await pageTemplate.copy(sp.web, “Page Name”, “Page Title”, false); |
Step 7
If true the page is published, if false the changes are persisted to SharePoint but not published [Default: true]
How to update the property of web parts while creating a copy of page
1 |
let WebpartPageWebpartInstance: string[] = this.getPageCustomWebPartsInstances(newPage); |
SharePoint Hosting – Document Sets In Modern SharePoint Libraries
Nov 26th
Enabling Document Sets in a Modern SharePoint Site
- Users can select the Shared Columns, these are the columns that will sync the metadata properties from Document Set to the documents inside it
- Users can select the columns to be displayed in Welcome Page View. This capability specifically differs from the folders. While folders will follow the same view, document sets give users an option to have a separate view that can have columns different from the parent view
- Users can run Workflows on Document Sets. This capability is especially helpful in scenarios where you have multiple documents under a project or agreement that needs to be approved together. If you approve the document set, it can then be applied to all the documents inside it
- No welcome page in Modern Document Sets. Technically, you still have the Welcome Page option in Document Set settings, but when the Welcome Page is customized, it changes the experience to Classic Mode.
- No versioning on Modern Document Sets. Since document sets have metadata associated with it, it would have been better if we could see the versions to identify the property changes. Versioning would still work on the documents inside the Document Sets though.
SharePoint Hosting – What Is SharePoint Framework (SPFx)?
Nov 19th
Background
Objective
SharePoint Hosting – Upload Nested Folder Structure And Files On A SP Online Library
Aug 31st
Hi guys, let’s explore some amazing ways to completely migrate a nested folder structure with lots of different files which is from your local path to a SP online library using PnP PowerShell.
Here is the script to run on Windows ISE Powershell:
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 |
#Function to Copy Multiple Files with Folder structure to SharePoint Online Document Library Function Migrate - PnPFolderToSPO() { param( [Parameter(Mandatory = $true)][string] $SiteURL, [Parameter(Mandatory = $true)][string] $SourceFolderPath, [Parameter(Mandatory = $true)][string] $LibraryName, [Parameter(Mandatory = $true)][string] $LogFile) Try { Add - content $Logfile - value "`n---------------------- File Upload Script Started: $(Get-date -format 'dd/MM/yyy hh:mm:ss tt')-------------------" #Connect to PnP Online Connect - PnPOnline - Url $SiteURL - UseWebLogin #Get the Target Folder to Upload $Web = Get - PnPWeb $List = Get - PnPList $LibraryName - Includes RootFolder $TargetFolder = $List.RootFolder $TargetFolderSiteRelativeURL = $TargetFolder.ServerRelativeURL.Replace($Web.ServerRelativeUrl, "") #Get All Items from the Source $Source = Get - ChildItem - Path $SourceFolderPath - Recurse $SourceItems = $Source | Select FullName, PSIsContainer, @ { Label = 'TargetItemURL'; Expression = { $_.FullName.Replace($SourceFolderPath, $TargetFolderSiteRelativeURL).Replace("\"," / ")}} Add - content $Logfile - value "Number of Items Found in the Source: $($SourceItems.Count)" #Upload Source Items from Fileshare to Target SharePoint Online document library $Counter = 1 $SourceItems | ForEach - Object { #Calculate Target Folder URL $TargetFolderURL = (Split - Path $_.TargetItemURL - Parent).Replace("\"," / ") $ItemName = Split - Path $_.FullName - leaf #Replace Invalid Characters $ItemName = [RegEx]::Replace($ItemName, "[{0}]" - f([RegEx]::Escape([String] '\"*:<>?/\|')), '_') #Display Progress bar $Status = "uploading '" + $ItemName + "' to " + $TargetFolderURL + " ($($Counter) of $($SourceItems.Count))" Write - Progress - Activity "Uploading ..." - Status $Status - PercentComplete(($Counter / $SourceItems.Count) * 100) If($_.PSIsContainer) { #Ensure Folder $Folder = Resolve - PnPFolder - SiteRelativePath($TargetFolderURL + "/" + $ItemName) Write - host "Ensured Folder '$($ItemName)' to Folder $TargetFolderURL" Add - content $Logfile - value "Ensured Folder '$($ItemName)' to Folder $TargetFolderURL" } Else { #Upload File $File = Add - PnPFile - Path $_.FullName - Folder $TargetFolderURL Write - host "Uploaded File '$($_.FullName)' to Folder $TargetFolderURL" Add - content $Logfile - value "Uploaded File '$($_.FullName)' to Folder $TargetFolderURL" } $Counter++ } } Catch { Write - host - f Red "Error:" $_.Exception.Message Add - content $Logfile - value "Error:$($_.Exception.Message)" } Finally { Add - content $Logfile - value "---------------------- File upload Script Completed: $(Get-date -format 'dd/MM/yyy hh:mm:ss tt')-----------------" } } #Call the Function to Upload a Folder to SharePoint Online Migrate - PnPFolderToSPO - SiteURL "https://samplesharenet.sharepoint.com/sites/classictest" - SourceFolderPath "C:\Users\Bharat\Documents\Bharat\General Works for Internal Requirements" - LibraryName "PnPCopytoLib" - LogFile "C:\Users\Bharat\PnPTest\Migration-LOG.log" |
Just enter your own respective details which are highlighted in the above script.
When it starts running, enter your Site Admin/Global Admin Tenant details to start the processing.
You can see the Uploading in Progress on your Windows Powershell ISE Interface. Just wait until it gets finished!
This script copies the contents of a folder to the SharePoint Online document library. It overwrites any existing file in the target SharePoint Online library. It creates a folder if it doesn’t exist on the target site already. We can also use this script to migrate files and folders from network file share to SharePoint Online document library!
Creative Idea
You can have the above script triggered through a Flow/Azure Flow[Logic Apps] to have an automated Copying and include Removal in the Source to establish an Automated Archival Process for your Business needs.
SharePoint Hosting – List All Content Editor Webparts Present In A SharePoint OnPremise Web Application Using PowerShell
Aug 24th
- PowerShell
- SharePoint 2016
Power Shell File
- [CmdletBinding()]
- param( [Parameter(Position=0,Mandatory=$true,ValueFromPipeline=$false,HelpMessage=“Input the Web Application URL.”)] [string]$WebApp)
1 2 3 4 |
if ((Get - PSSnapin - Name Microsoft.SharePoint.PowerShell - ErrorAction SilentlyContinue) - eq $null) { Write - Host "Loading SharePoint PowerShell" Add - PSSnapin Microsoft.SharePoint.PowerShell } |
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 |
$SPWebApp = Get - SPWebApplication $WebApp - EA SilentlyContinue if ($SPWebApp - eq $null) { Write - Error "$WebApp url is not a valid!" } else { $allsites = $SPWebApp.Sites foreach($site in $allsites) { try { $allwebs = $site.AllWebs foreach($web in $allwebs) { try { if ([Microsoft.SharePoint.Publishing.PublishingWeb]::IsPublishingWeb($web)) { $pubpages = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web) $allpages = $pubpages.GetPublishingPages() foreach($page in $allpages) { GetCEWPFunction - url $page.Url } } } catch {} finally { $web.Dispose() } } } catch {} finally { $site.Dispose() } } } |
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 |
GetCEWPFunction - url $page.Url } } $lists = $web.GetListsOfType("DocumentLibrary") | ? { $_.IsCatalog - eq $false } foreach($list in $lists) { $allviews = $list.Views foreach($view in $allviews) { GetCEWPFunction - url $view.Url } $allforms = $list.Forms foreach($form in $allforms) { GetCEWPFunction - url $form.Url } } } catch {} finally { $web.Dispose() } } } catch {} finally { $site.Dispose() } } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
function GetCEWPFunction([string] $url) { $manager = $web.GetLimitedWebPartManager($url, [System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared) $allwebParts = $manager.WebParts if ($allwebParts.Count - ne 0) { foreach($webPart in $allwebParts) { if ($webPart.GetType() - eq[Microsoft.SharePoint.WebPartPages.ContentEditorWebPart]) { if ($webPart.ContentLink.Length - gt 0) { $file = $web.GetFile($webPart.ContentLink) $data = $file.OpenBinary() $encode = New - Object System.Text.ASCIIEncoding $contents = $encode.GetString($data) if ($contents.ToLower().Contains("<script>")) { Write - Output "$($web.Url)/$url (CONTENTLINK)" } break } if ($webPart.Content.InnerText.Contains("<script>")) { Write - Output "$($web.Url)/$url (HTML)" } } } } } |