European Sharepoint 2013 Hosting Blog
Articles about European Sharepoint Hosting Service
Articles about European Sharepoint Hosting Service
Jun 21st
A SharePoint library is a location on a site where you can upload, create, update, and collaborate on files with team members. To remove an empty folder from the library is difficult since we need to go to each and every library and identify whether it is empty or not. Then, we have to remove it from the library. To automate this process, I used Powershell scripting because it is easy to parse through each and every library using PNP library. So it is easy to identify and remove the empty folders in SharePoint library
Prerequisite
Before you begin utilizing PowerShell to oversee SharePoint Online, ensure that the SharePoint Online Management Shell is installed. You can install the SharePoint Online Management Shell by downloading and running the SharePoint Online Management Shell. You only need to do this once for each computer from which you are running SharePoint Online PowerShell commands.
Connect to Site
Connect to SharePoint site using Connect-PnPOnline cmdlet. The required parameters are,
-Url
The SharePoint site URL (Eg: https://hubflysoft.sharepoint.com/sites/Hubfly)
The following code snippet helps to connect SharePoint sites.
1 2 3 |
$siteurl="https://<tenant-name>.sharepoint.com" Connect-PnPOnline -Url $siteurl |
Get Web Instance using Get-PnPWeb
$web = Get-PnPWeb
The Get-PnPWeb cmdlet actually has its own Recurse option, and you could use that if you want to rather than doing your own recursion.
Get User Context using Get-PnPContext
$context = Get-PnPContext
The Get-PnPContext returns a Client Side Object Model context. This command is very handy and it returns the current context. You might need context because it might be the case you need to save the current context. By switching between two sites you need this.
Get folders from the library using Get-PnPFolder
1 |
$folder = Get-PnPFolder -RelativeUrl "Shared Documents" |
The Get-PnPFolder returns the folder called ‘Shared Documents’ which is located in the root of the current web.
Get all subfolders and remove empty folders
Using the context we need to load all files, folders, and Parent folder like below code snippet
We can find the folder is empty by the following conditions,
And remove the empty folders using below PS script
1 2 3 4 5 6 7 8 9 10 11 12 |
Remove - PnPFolder if ($folder.Files.Count - eq 0 - and $folder.Folders.Count - eq 0 - and(($folder.Name - notmatch 'Document') - and($folder.Name - notmatch $libraryName))) { $path = $folder.ParentFolder.ServerRelativeUrl.Substring($web.ServerRelativeUrl.Length) Write - Host "Removing folder " $folder.ServerRelativeUrl.Substring($web.ServerRelativeUrl.Length) Remove - PnPFolder - Folder $path - Name $folder.Name - Recycle - Force $folders_list += $folder.Name + ", " + $folder.ServerRelativeUrl } Write - Host "Searching for empty folders. Please wait..." $folders_list = GetAllSubFolders $folder $context Write - Host $libraryName 'Completed' |
I hope you learned how to remove empty folders and files in the SharePoint library programmatically using PnP PowerShell scripting. The operations mentioned above are tested on SharePoint Online environment. Feel free to leave a comment below, if you need any assistance.
Jun 7th
In this tutorial, I will explain you how to to Configure existing URL located in the Top Navigation Bar as the referenced site URL has changed in SharePoint 2013.
The top link bar helps users of your site navigate to alternative sites within the site collection by displaying a row of tabs at the top of pages in the site. the top link bar is additionally referred to as global navigation, as a result of it can be the same across all of the web sites in a site collection. However, subsites can be configured to not show in the top link bar of the parent site. the options offered to you for configuring your top link bar will vary depending on whether or not the publishing features are enabled for your site collection.
I want to change this hyperlink to all sites inside the Web App: more than 1800 Site Collection. And I use the following code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
$Webs = Get-SPSite -WebApplication "http://SharePoint.Contoso.com" -limit ALL | Get-SPWeb -limit all Foreach($Web in $Webs) { $TN = $Web.Navigation.TopNavigationBar | Where-Object {$_.Title -eq "Landing Page & Wiki"} if ($TN.url -like "http://hostforlife.eu*") { write-host "Updating $($Web.url)" “Updating $($Web.url), $($TN.Url)” | out-file D:\temp\LandingPageUpdate.csv -append $TN.Url = "http://NewSharePoint.Contoso.com/Pages/LandingPageWikiDefault.aspx" $TN.update() } } #---------------------------------------------------------------------- |
Also, in parallel, I had to modify the template used to create the new sites into this Web App. Doing this will avoid having to run this script periodically to correct the changes.
HostForLIFE.eu’s SharePoint 2013 Hosting solution offers a comprehensive feature set that is easy-to-use for new users, yet powerful enough for the most demanding web developer expert. Hosted SharePoint Foundation 2013 is the premiere web-based collaboration and productivity enhancement tool on the market today. With SharePoint 2013 Foundation, you can quickly access and manage documents and information anytime, anywhere though a Web browser in a secure and user friendly way. SharePoint hosting services start at only at €9.99/mo, allowing you to take advantage of the robust feature set for a small business price. HostForLIFE.eu offers a variety of hosted SharePoint Foundation 2013 plans as well as dedicated SharePoint 2013 Foundation options
May 31st
In this tutorial, I will explain you how to to Configure existing URL located in the Top Navigation Bar as the referenced site URL has changed in SharePoint 2013.
The top link bar helps users of your site navigate to alternative sites within the site collection by displaying a row of tabs at the top of pages in the site. the top link bar is additionally referred to as global navigation, as a result of it can be the same across all of the web sites in a site collection. However, subsites can be configured to not show in the top link bar of the parent site. the options offered to you for configuring your top link bar will vary depending on whether or not the publishing features are enabled for your site collection.
I want to change this hyperlink to all sites inside the Web App: more than 1800 Site Collection. And I use the following code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
$Webs = Get-SPSite -WebApplication "http://SharePoint.Contoso.com" -limit ALL | Get-SPWeb -limit all Foreach($Web in $Webs) { $TN = $Web.Navigation.TopNavigationBar | Where-Object {$_.Title -eq "Landing Page & Wiki"} if ($TN.url -like "http://hostforlife.eu*") { write-host "Updating $($Web.url)" “Updating $($Web.url), $($TN.Url)” | out-file D:\temp\LandingPageUpdate.csv -append $TN.Url = "http://NewSharePoint.Contoso.com/Pages/LandingPageWikiDefault.aspx" $TN.update() } } #---------------------------------------------------------------------- |
Also, in parallel, I had to modify the template used to create the new sites into this Web App. Doing this will avoid having to run this script periodically to correct the changes.
HostForLIFE.eu’s SharePoint 2013 Hosting solution offers a comprehensive feature set that is easy-to-use for new users, yet powerful enough for the most demanding web developer expert. Hosted SharePoint Foundation 2013 is the premiere web-based collaboration and productivity enhancement tool on the market today. With SharePoint 2013 Foundation, you can quickly access and manage documents and information anytime, anywhere though a Web browser in a secure and user friendly way. SharePoint hosting services start at only at €9.99/mo, allowing you to take advantage of the robust feature set for a small business price. HostForLIFE.eu offers a variety of hosted SharePoint Foundation 2013 plans as well as dedicated SharePoint 2013 Foundation options
May 24th
On click of the Cusom Edit Link, it will be redirected to my custom edit page which I have created under list form.
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 |
<script language="javascript" type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script> <script language="javascript" type="text/javascript"> $(document).ready(function() { SP.SOD.executeFunc('sp.js', 'SP.ClientContext', AddCustomUserActionToECB); }); function AddCustomUserActionToECB() { var clientContext = new SP.ClientContext(); var oWeb = clientContext.get_web(); var oList = oWeb.get_lists().getByTitle('ComplainTracking'); var userCustomActionColl = oList.get_userCustomActions(); clientContext.load(oList, 'UserCustomActions', 'Title'); clientContext.executeQueryAsync(function() { var customActionEnumerator = userCustomActionColl.getEnumerator(); var foundAction = 0; while (customActionEnumerator.moveNext()) { var oUserCustomAction = customActionEnumerator.get_current(); if (oUserCustomAction.get_title() == 'Custom Edit Page') { //oUserCustomAction.deleteObject(); //clientContext.load(oUserCustomAction); //clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceededdelete), Function.createDelegate(this, this.onQueryFailed)); foundAction = 1; break; } } if (foundAction == 0) { var oUserCustomAction = userCustomActionColl.add(); oUserCustomAction.set_location('EditControlBlock'); oUserCustomAction.set_sequence(100); oUserCustomAction.set_title("Custom Edit Page"); //oUserCustomAction.set_url("/sites/QA/SL_MI/SitePages/CustomSearch.aspx?ListId={ListId}&ItemId={ItemId}&ItemUrl={ItemUrl}"); oUserCustomAction.set_url("/sites/QA/SL_MI/Lists/ComplainTracking/Edit1.aspx?ID={ItemId}&Source=/sites/QA/SL_MI/SitePages/ListViewGrid.aspx"); oUserCustomAction.update(); clientContext.load(userCustomActionColl); clientContext.executeQueryAsync(); } }, function(sender, args) { console.log('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace()); }); } </script> |
May 17th
May 3rd
In this article I would like to share the steps to create post list in SharePoint team site. By default, post list is available in blog template site.
I got a requirement that a customer needs the post list in the SharePoint team site, but post list template is not available in SharePoint team site. There is a solution to create post list in SharePoint team site by activating the feature.
What is blog post list and why do we need post list?
Here is the code to activate the “Blog content” feature.
Add the below code in content editor webpart or script editor webpart.
The list will be created on your team site, those lists are relevant to the blog feature. In this article we have learned how to create a post list in SharePoint team site. Now you can enjoy the blog feature in team sites as well.