Sunday 6 December 2020

Change SharePoint Online list or library Internal name

 Change SharePoint Online list or library Internal name 

Issue:

Recently we have provided a build and guideline document to our client and by mistake they have set up a library with wrong internal name. In starting it worked well but as the additional functionality added, it broke. As the users have started working on that, we needed to fix the internal name anyway. 

Our library internal name is “TrainingDocuments” and display name is “Training Documents”. While Client has set up “Training Documents”.



Solution

Initially we thought it might be not possible. But then we found 2 ways to do it:

Approach 1: Using SharePoint Designer 2013

Follow below steps to fix this using SharePoint Designer 2013:

  1. In SharePoint Designer, Open your site.
  2. Navigate to All Files navigation node (not List and Libraries node),
    Note – you will need “Site Collection Administrator” permission in the site collection to see “All Files” option.
  3. Find your list there
  4. Right-click list
  5. Rename.



Approach 2 : Using PNP PowerShell

In case you are not able to connect the site in the SharePoint designer or you do not have installed in your machine, you can do this using PNP PowerShell as well. 


PowerShell to change Library Name:

 #Set Parameters  
 $SiteURL = "Site URL"  
 $ListName = "Library Internal Name"  
 $NewListURL = "New Library Name"  
 #Connect to PNP Online  
 Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential)  
  #this will change URL  
 #Get the List  
 $List= Get-PnPList -Identity $ListName -Includes RootFolder  
 #sharepoint online powershell change list url  
 $List.Rootfolder.MoveTo($NewListURL)  
 Invoke-PnPQuery  
 #this will change library title  
 Set-PnPList -Identity $ListName -Title $NewListURL  


PowerShell to change List Name:

 #Set Parameters  
 $SiteURL = "Site URL"  
 $ListName = "Library Internal Name"  
 $NewListURL = "New Library Name"  
 #Connect to PNP Online  
 Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential)  
 Set-PnPList -Identity $ListName -Title $NewListURL  

File server migration to SharePoint online using SPMT PowerShell Part 2

In previous blog we have go through the csv creation part. You can find it on below link:

In this blog, we are going to use that file and SPMT migration PowerShell commands to migrate file server to SharePoint online.

Prerequisite

SharePoint Migration Tool needs to be installed in the machine

Solution

First, we are going to get credentials for

 Import-Module Microsoft.SharePoint.MigrationTool.PowerShell  
 $Global:SPOUrl = "SharePoint site collection url"  
 $Global:UserName = "username"  
 $Global:PassWord = ConvertTo-SecureString -String "Password" -AsPlainText -Force  
 $Global:SPOCredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $Global:UserName, $Global:PassWord  

 

After this we will read csv file

 #Load CSV  
 $csvItems = import-csv "C:\Migration\migrationscript.csv" -Header c1,c2,c3,c4,c5,c6  

 

Now we will register migration task. This needs to be done once for all migration task. So we will keep this out of for loop

 Register-SPMTMigration -SPOCredential $Global:SPOCredential -Force -MigrateWithoutRootFolder -PreserveUserPermissionsForFileShare $true  

 

We are passing below two parameters

  1. MigrateWithoutRootFolder – This will not migrate parent folder. Only items withing the given path directory will be migrated. This is not mentioned in the MSDN link, but it is mentioned in the build changes document. This was included in build –  3.4.119.7

  2. PreserveUserPermissionsForFileShare – This parameter is used if you want to migrate file server permission to SharePoint online

 

Now we will loop through csv file and add migration task.

 ForEach ($item in $csvItems)  
 {       
   Write-Host $item.c1  
   Add-SPMTTask -FileShareSource $item.c1 -TargetSiteUrl $item.c4 -TargetList $item.c5 -TargetListRelativePath "/"  
 }  

 

After this we will start migration

 Start-SPMTMigration  

 

The full PowerShell will look like below:

 Import-Module Microsoft.SharePoint.MigrationTool.PowerShell  
 $Global:SPOUrl = "SharePoint site collection url"  
 $Global:UserName = "username"  
 $Global:PassWord = ConvertTo-SecureString -String "Password" -AsPlainText -Force  
 $Global:SPOCredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $Global:UserName, $Global:PassWord  
 #Load CSV  
 $csvItems = import-csv "C:\Migration\migrationscript.csv" -Header c1,c2,c3,c4,c5,c6  
 Register-SPMTMigration -SPOCredential $Global:SPOCredential -Force -MigrateWithoutRootFolder -PreserveUserPermissionsForFileShare $true  
 ForEach ($item in $csvItems)  
 {  
   Write-Host $item.c1  
   Add-SPMTTask -FileShareSource $item.c1 -TargetSiteUrl $item.c4 -TargetList $item.c5 -TargetListRelativePath "/"  
 }  
 Start-SPMTMigration  

 

Reference

File server migration to SharePoint online using SPMT PowerShell Part 1

Recently we have a project where we need to migrate file server to SharePoint Online. So, we decided to go with SharePoint Migration Tool (SPMT). But we had 50 plus folders and all were needed to migrate to different sites documents library. As it takes long time to migrate using tool due to creating connection, we decided to use PowerShell version.

 

Issue

We faced below issues in this requirement:

  1. The documentation for this is not that accurate or in single place. We need to search here and there for things.
  2. SPMT tool migrates file server child items directly but when you use PowerShell, it migrates parent folder. Due to curse of first point, it took some time for us to find the hidden solution. Go through this post to see that hidden gem.
  3. The last but no least is permission migration. SPMT has all this functionality but as I said earlier it is not documented well.

So, we will try to explain all our knowledge in detail here.

 

Solution -

 

First, we need to prepare a csv which will be read by PowerShell and It will have connection details of source and migration.

important notes for preparing csv:

  1. Do not include a header row in your CSV file.
  2. Remember to account for all six columns in the file, even if you are not needing a value for a given field.
  3. 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.

Note - If the language of the destination SharePoint site is other than English, check the Display name of the "Shared Documents" Document library by browsing to Documents library.

The format of csv is as below:

Source,SourceDocLib,SourceSubFolder,TargetWeb,TargetDocLib,TargetSubFolder


As we are migrating from file server, we will not pass the “SourceDocLib” & “SourceSubFolder” details. So, our csv detail will look like below:

File server path,,, TargetWeb,TargetDocLib,TargetSubFolder

For example,

C:\MigrationTests\testfiles,,,https://contoso.sharepoint.com/sites/Sample/,DocLibraryName,DocLibraryName_subfolder

 

In case, you don’t want to migrate it to sub folder, the subfolder part will be blank

File server path,,, TargetWeb,TargetDocLib,

For example,

C:\MigrationTests\testfiles,,,https://contoso.sharepoint.com/sites/Sample/,DocLibraryName,

In next blog we will use this csv in the PowerShell.

Reference:
  1. https://docs.microsoft.com/en-us/sharepointmigration/how-to-format-your-csv-file-for-data-content-migration#:~:text=number%20of%20tasks.-,Using%20a%20comma%20separated%20value%20(CSV)%20file%20for%20data%20content,to%20create%20the%20CSV%20file

Saturday 3 October 2020

Advantage & Limitations of SharePoint Online Modern Communication Site Footer

In our previous posts we have seen how can we enable Footer, How to add, edit remove footer logo and links and set up audience targeting in Footer links. If you have not gone through that you can use below links to checkout it out:

So Let's see what is Advantage & Limitations of the Modern Footer.

Limitations
  • OOTB footer is available for only Modern communication sites. For Modern Team sites, it is not available

    This is the biggest obstacle to use OOTB Footer. You can't have it in Modern Team site template. So if your site structure has even a single modern Team site, you need to build your own custom SPFx Footer.  

  • OOTB Footer will not be visible in mobile resolution
    I believe with digitalization all around the world, people use their tablet and mobile more than their laptop and desktop. And Modern footer is not available in that is second biggest flaw. 

  • OOTB Footer will not be visible in site content, List/ Libraries and in classic settings/Site pages like settings pages
    It is not visible in site content, list and libraries as well in Modern Communication Site. Also as these are modern feature, they will not visible in classic pages like site settings or classic site or publishing pages.

  • You can set Max 8 links/ Label in OOTB Footer except logo and footer display name
    8 Links - is very less limit. For simple layout footer we can see it will feasible but if you have extended footer layout, it looks very limited.

  • External user can not edit the footer even though you have given them full control rights
    I believe this is due to security concerns. 

  • You can not use SharePoint site groups for Audience targeting
    You need to use office 365 security groups or Modern team sites office 365 groups for the audience targeting. In this scenario, if you have just site collection admin rights, you are not able to do anything. In classic SharePoint, SharePoint groups were there. So I hope Microsoft might find a way to bring that back.

Advantage
  • Easy to configure
    The good thing is you don't need to know rocket science to configure this. Just enable a toggle button and add some links and you have a footer ready. 

    You are given a 2 types of layout to choose from. Also you can make changes in each site as per your requirement as all sites have their own footer.

  • End user or client can maintain this by themselves with minimal guidance
    This is toughest job as handover to client. You need to make sure once your work is done, anyone with given guideline can maintain things. And in compare to customized SPFx extension it will be less easy to train uses to use OOTB Footer

  • Does not occupy space on the page
    This is the best thing about that. OOTB footer append at the end of the page. Means you have full body visible. In custom SPFx, the footer will have its own part at the page. So the body content reading is an issue. See below images for example.
OOTB Footer




SPFx Extension


You can go with OOTB as well custom SPFx Footer as per your requirement. If you want to go with OOTB Footer, please convey the limitations to the end client first.

This is the end of our Footer Series. Let me know if you have any queries, then I will be happy to answer. 

Reference
  • https://docs.microsoft.com/en-us/sharepoint/dev/features/site-footer
  • https://support.microsoft.com/en-us/office/customize-the-navigation-on-your-sharepoint-site-3cd61ae7-a9ed-4e1e-bf6d-4655f0bf25ca?ui=en-us&rs=en-us&ad=us

Different Layout in SharePoint Online Modern Communication Site Footer

 In our previous posts we have seen how can we enable Footer, How to add, edit remove footer logo and links and set up audience targeting in Footer links. If you have not gone through that you can use below links to checkout it out:

So Let's see what are the layout options available in OOTB Footer and how to find this setting:

Follow below steps to check footer layout option:

  • Go to Setting -> Change the look -> Footer.
    (you can find steps in detail in first blog)


There are two types of footer layout available:
  • Simple
    In Simple layout the footer links will place in horizontal. See below screenshot for the reference:


  • Extended
    In Extended layout the footer links will place in in full width row. If the width of the link is extended, it will show in new row. See below screenshot for the reference:

You can use simple or extended layout as per your requirement. In both, you can use 8 links, Footer logo and text as per your requirement.

In next article, we will see the advantage and limitations of OOTB Footer.

Sunday 13 September 2020

How to set up Audience Targeting in Footer links in Modern Communication Site?

In previous blogs we learn how can we enable footer, set logo and footer text and add & Edit footer links on SharePoint Online Modern Communication site. If you have not gone through that you can use below link to check that post.

In this blog, we are going to see how we can set audience targeting on the links. So, let's start with pre-requisites:

Pre-requisites:

We will need below things to set up audience targeting:
  • The site owner must enable audience targeting for site navigation.
    Only site owners can turn audience targeting on and off. Once turned on, any site editor can target menu links to specific audiences.
  • The Office 365 Admin user must set up Microsoft 365 groups and security groups.
    Currently Azure AD dynamic groups & SharePoint site groups are not currently supported. Though to overcome this, you can set up SharePoint Modern Teams sites with Office 365 groups and use that group in audience targeting.
Enable & Add Groups in Audience Targeting

Follow below steps to enable Audience Targeting:
  • Scroll to the bottom of the page.

  • Click on Edit.
    Note – If you do not see this, then you do not have enough permission.

  • It will open new panel in the left side of the screen.


  • Enable Site navigation audience targeting.
    Note - If you do not see this, then you do not have enough permission.


  • Once you enable this setting, you will see audience targeting text box while add, edit links.


  • When you start typing, it will provide auto suggest groups. For this blog, I am choosing one of my team site group for home link.


  • You can select up to 10 groups. 
  • Click Ok. 


  • Then you can see audience targeting icon beside the link.


  • Click save to save changes.


Note - While editing the navigation, all links and sub links become visible to the editor including those that are targeted. Once saved, the navigation will display to targeted users only. 

You can login with other user and check the link is hidden.




In next blog, we will check the layout options for the footer.

Thursday 30 July 2020

How to add, edit and Remove Footer links in Modern communication site

In previous blogs we learn how can we enable footer and set logo and footer text on SharePoint Online Modern Communication site. If you have not gone through that you can use below link to check that post.


In this blog, we are going to see what are the options to add links. So let's get started.

Once you enable footer, you can see footer in the bottom of the footer.

Add Footer Links:
To add footer links, follow below steps:
  • Scroll to the bottom of the page.
  • Click on Edit.
    Note – If you do not see this, then you do not have enough permission.
  • It will open new panel in the left side of the screen.

  • If you want to display links to specific group, enable Site navigation audience targeting. We will discuss about this in detail in next blog

  • Click on “+” icon to add new link.
  • When you click “+” icon, it will open dialog besides it. You need to fill below values:
    • Choose whether you want to add link or label
      • If you select link, you can provide “Address”. In this you can specify URL where user will be redirect on click.

      • If you select label, address field is disabled.

    • Provide Display Name. 
    • Click OK.
  • Repeat above steps to add more links/ label. You can total 8 links. After 8 links add button will be disabled.

  • Click “Save” once all changes are done.
  • Refresh page to see result if you don't see changes after save click.

Edit Footer Links:
    To edit footer text, follow below steps:
    • Scroll to the bottom of the page. 
    • Click on Edit.
      Note – If you do not see this, then you do not have enough permission.

    • It will open new panel in the left side of the screen.
    • Click on “…” beside link / label. 
    • It provides multiple options like
      • Edit - It will provide option to edit
      • Move Up - It will move current link to one step up.
      • Move Down - It will move current link to one step down. 
      • Remove - It will remove the link

    • Click on Edit.
    • It will open edit link dialog. This will be same as we explain in add link.
    • Make changes and click OK.
    • Click Save.
    • Refresh page to see result if you don't see changes after save click

    Remove Footer Links:
    To remove footer text, follow below steps:
    • Scroll to the bottom of the page. 
    • Click on Edit.
      Note – If you do not see this, then you do not have enough permission.

    • It will open new panel in the left side of the screen.
    • Click on “…” beside link / label. It will provide multiple option. 
    • Click on remove.

    • Click Save.
    • Refresh page to see result if you don't see changes after save click.


    In next blog we will check out the audience targeting settings for the Footer links. 

    Monday 27 July 2020

    How to set footer logo and footer text in Modern communication site

    In last blog we learn how can we enable footer on SharePoint Online Modern Communication site. If you have not gone through that you can use below link to check that post.

    In this blog, we are going to see what are the options to set logo and text. So let's get started.

    Follow below steps to set footer logo:

    • Go to Setting -> Change the look -> Footer.
      (you can find steps in detail in first blog)
    • There you can see upload logo option. Click upload. Select the file from your local system. 

    • Click save

    • It will be displayed to footer.

    To add footer text, follow below steps:
    • Go to Settings -> Change the look -> Footer
    • Add text in display name.

    • Click Save.
    • It will show in the left bottom corner.

    In next blog we will see how we can set footer links. What are layout option to show the links and what are the limitation of the Modern footer.

    Saturday 25 July 2020

    How to enable Footer in a SharePoint Modern Communication Site

    SharePoint Online introduce Modern Sites and with it introduce OOTB Footer. Generally we are not used to it but one of our customer wanted to learn more about it and asked us to prepare document on it.

    We thought as it has been some time, we will get detailed blog on it easily. But it seems it is been described only in Microsoft Document. And I have put reference of it in the end of this post. It is good but it seems very less described and not updated with new updates. So I am trying to explain it in as detail as I can in this footer series. So lets get started.

    First of all we need to make sure the Footer is enabled in the Modern Communication SharePoint site.

    Notes -
    • Footer is not available in Modern Team site as of now.  
    • Footer will be enabled by default for all new communication sites after the feature is rolled out. If you can see the footer on your modern communication site, skip this steps
    Follow below steps to enable the Footer:
    • Click on “Settings”.
    • Click on “Change the look” option.
      Note – If you are not seeing this option then you do not have enough permission on this site.



    • Click on Footer

    • Make sure footer is enabled. If not enable it.

    • Once you enable, it will show different option. We will look in to them in next post. Click Save.

    • Once your enable it , it will display in the bottom of the page.


    You can enable this using PowerShell as well. For this you will need PNP Powershell installed in your system. In case you don't have PNP PowerShell Set up, check this blog.

    Below is PNP PowerShell command to enable footer:

    Connect-PnPOnline -Url "<SiteURL>" –Credentials (Get-Credential) 
    Set-PnPFooter -Enabled:$false

    Lets configure the footer in the next blog.

    Reference:
    https://docs.microsoft.com/en-us/sharepoint/dev/features/site-footer

    Wednesday 1 April 2020

    Office 365/SharePoint Online - PowerShell Script to get Unique Visitors & Total Views count for Site Page

    Problem Statement -

    We have a client with a large SharePoint Tenant, want to know the Total Views count along with Unique Visitors count for each Post/Page, they are adding every day for their employees.

    Analysis -

    Currently, Microsoft is working on Analytics API that is supposed to give you the details regarding total view count and unique view count for specific item. Even though it is released but not working for a single item.

    The alternative way is to use the SharePoint Search API. This will use Microsoft Classic Search results and provide you count based on that.

    Resolution -

    We have decided to go with the SharePoint Search API approach. We have found an article with the same idea. The only concern was, using Search API directly can return max 500 rows as a result at a time. So, we need to generalize that script in such a way that it can be executed for all items in the list/library.

    So, here is generalized the Power-Shell script:

    Step 1 - Load required dependencies/assemblies:
    # Paths to SDK. Please verify location on your computer.  
     #Add-PSSnapin Microsoft.SharePoint.PowerShell  
     [System.Reflection.Assembly]::LoadFrom("C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll")  
     [System.Reflection.Assembly]::LoadFrom("C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll")  
     [System.Reflection.Assembly]::LoadFrom("C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Search.dll") 

    Step 2 - Create a Function - to get all list items and using search query to retrieve ViewsLifeTime & ViewsLifeTimeUniqueUsers for each item:
    function Get-SPOListView  
     {  
       param(  
       [Parameter(Mandatory=$true,Position=1)]  
       [string]$Username,  
       [Parameter(Mandatory=$true,Position=2)]  
       $AdminPassword,  
       [Parameter(Mandatory=$true,Position=3)]  
       [string]$Url,  
       [Parameter(Mandatory=$true,Position=4)]  
       [string]$ListTitle  
       [Parameter(Mandatory=$true,Position=5)]  
       [string]$TenantUrl  
       )  
      #Get the SharePoint List/Library.
       $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url)  
       $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $AdminPassword)  
       $ll=$ctx.Web.Lists.GetByTitle($ListTitle)  
       $ctx.load($ll)  
       $ctx.ExecuteQuery()  
      #Get all items from the List/Library.
       $qry = [Microsoft.SharePoint.Client.CamlQuery]::CreateAllItemsQuery()  
       $items = $ll.GetItems($qry)   
       $ctx.Load($items)  
       $ctx.ExecuteQuery()  
       foreach($listItem in $items)  
       {  
         Write-Host "ID - " $listItem["ID"] "Title - " $listItem["Title"] "EncodedAbsUrl - " $listItem["FileRef"]     
         $fileurl = $TenantUrl+ $listItem["FileRef"]  
         #Using Search API - Create the instance of KeywordQuery and set the properties.
         $keywordQuery = New-Object Microsoft.SharePoint.Client.Search.Query.KeywordQuery($ctx)   
         #Sample Query - To get the result of last year.
         $queryText="Path:" + $fileurl  
         $keywordQuery.QueryText = $queryText  
         $keywordQuery.TrimDuplicates=$false  
         $keywordQuery.SelectProperties.Add("ViewsLifeTime")  
         $keywordQuery.SelectProperties.Add("ViewsLifeTimeUniqueUsers")  
         $keywordQuery.SortList.Add("ViewsLifeTime","Asc")   
         #Search API - Create the instance of SearchExecutor and get the result.
         $searchExecutor = New-Object Microsoft.SharePoint.Client.Search.Query.SearchExecutor($ctx)  
         $results = $searchExecutor.ExecuteQuery($keywordQuery)  
         $ctx.ExecuteQuery()  
         #Result Count  
         Write-Host $results.Value[0].ResultRows.Count  
         #CSV file location, to store the result  
         $exportlocation = "C:\Pages_ViewsCount - Copy.csv"  
         foreach($result in $results.Value[0].ResultRows)  
         {  
           $outputline='"'+$result["Title"]+'"'+","+'"'+$result["Path"]+'"'+","+$result["ViewsLifeTime"]+","+$result["ViewsLifeTimeUniqueUsers"]   
           Add-Content $exportlocation $outputline   
         }   
         #}  
       }  
     }

    Step 3 - Call the above function:
    # Insert the credentials along with Admin & Tenant URLs and Call above Function.  
     #Enter Username here  
     $Username="username@sharepoint.com"  
     #Enter Password Here  
     $Password=Read-Host -Prompt "Password" -AsSecureString  
     #URL of the site collection  
     $rootUrl= "Root Site collection URL"  
     $ListTitle= "Site Pages"  
     $TenantUrl= "Your tenant URL E.g. https://YourCompany.sharepoint.com"  
     Get-SPOListView -Username $Username -AdminPassword $Password -Url $rootUrl -ListTitle $ListTitle -TenantUrl $TenantUrl 

    It will export all items of the list with Total views count - ViewsLifeTime & Unique views count - ViewsLifeTimeUniqueUsers in excel sheet as shown in below image:


    In case you need the dll files, you can download from below link
    https://drive.google.com/file/d/1P9YzJUvCeAfnZ8xIr-7SKCN2fisbRP6a/view?usp=sharing

    References