Posts

Restoring a lot of files from the Recycle Bin

I had a customer who accidentally synched a (very large) SP Online library and then decided they didn't want the files on their PC anymore...so they deleted them and were shocked to learn that they'd been deleted from SharePoint too! Thanks to PnP Powershell you can use the following to restore a batch of files quickly (and filter). First, you'll want to make sure you only select the files you want to restore.  I used a combination of filtering by the person who deleted the files and the date they were deleted, e.g. Connect-PnPOnline https://yourtenanturl $restoreSet = Get-PnPRecycleBinItem | Where-Object { $_.DeletedByEmail -eq "imsorry@company.com" -and $_.DeletedDate -gt "1/1/2019" } Make sure you have a fairly updated version of the PnP Powershell module as the objects that come back have more properties populated than in older versions so you can do more powerful filtering Next you can restore the files like this: $restoreSet | Rest...

Scoped Bootstrap for SharePoint

I've got a project for a client that involves refactoring a lot of bad choices related to SharePoint branding in Classic mode sites.   (While I'm enthusiastic about the Modern Sites and new techniques using SPFx extensions, most of our customers are slow on the uptake). I've had to do this a few times and this blog explains it perfectly, but due to some formatting issues over there and a desire for just the steps as I need to update/repeat this, I've summarized here: Open up a node capable command prompt (I use cmd) Create a directory for your solution (e.g. C:\Repos\ScopedBootstrap) Run npm install bootstrap@3.3.7 (or whatever version you need to work with) Go into the node_modules\bootstrap\less directory  Open bootstrap.less in VS Code. Place  .YourUniqueClassName{  before all the @import statements and close the curly brace at the end of the file. Go back to the ..\bootstrap directory (in node_modules) Run npm install to install the dependenci...

Switching between on-prem and SharePoint Online versions of PnP Powershell Commands

I've updated my original post to just link to these instructions. This is a better way of doing it as you're explicitly loading the specific commands each time you need to run them, that way you're clear on which version you're using: https://www.erwinmcm.com/running-the-various-versions-of-pnp-powershell-side-by-side/   I use the PnP Powershell commands very frequently, but mostly only for SP Online.   Lately I've been working on a SP2013 customization and wanted to use the PnP PowerShell commands for SP2013. If you have multiple version of the commands installed then you'll need to select which one you want to use. This thread explains that you need to clear your PSMODULEPATH environment variables but then you'll need to an import-module when you need to work with a particular version.  Follow this guidance first:  https://github.com/SharePoint/PnP-PowerShell/issues/1356 Doing that is fine if you don't mind retyping your module path in the...

Client Side Override the Site Logo's link in an SharePoint Site

In SharePoint sites that have any kind of hierarchy of subwebs, it is frequently desirable to override the logo's link behavior to link back to the root of the site collection.   There's a bunch of guidance on how to do this by overriding the master page, but not much on how to do this client-side, to avoid MasterPage manipulation.   Here's a script that helps to do this: //update site icon link, SP overrides any direct reassignment so you have to change the existing ID //and then create a dummy element with the existing ID to avoid future JS errors. //read old link id var prevId = $("#DeltaSiteLogo > a").attr('id'); //change the id $("#" + prevId).attr({       'id':'CustomSiteLogo',       'title': 'Employee Portal Home',       'href':window.location.protocol + "//" + window.location.host }); $("#DeltaSiteLogo > a").after("<a id='" + prevId + "...

Connect-PnPOnline : For security reasons DTD is prohibited in this XML document. error

Until today I had never received this error when trying to connect to SPO.    If you get this error there's a good chance it's related to missing records on the DNS server your machine is relying upon.  If not set, there's a good chance you're using your ISP's DNS servers, whose records may not be as up to date as others.  The quick fix (at least for me) was to alter my DNS settings to point to more reliably up-to-date DNS.   Here's a how to fix this issu (on Windows 10, if you aren't using windows 10, follow your OS instructions on updating DNS settings and then just jump to step 4 below) along with a few options for DNS settings that I tested: Click Start and type "View Network Connections. Right-Click your adapter that connects to the internet and choose properties Choose TCP/IP v4 and then click the "Properties" button At the bottom of the IP v4 properties window, select the radio button that says "Use the following DNS Server ...

Reordering the default content type for document sets

Had a particularly annoying time with this as the document sets were already in use and was attempting to do this in SharePoint Online.    My scenario was that I was using document sets and only wanted document sets in the root folder.  So I set the other ctypes as not visible, but then the customer asked to default to one of the content types that wasn't previously set up at the top of the list, and I couldn't reorder in the "Document Set Setting" option of the document set content type because there's a multi-select box with no up/down functionality for these.   As a last ditch effort I went back to the List Settings and just made all content types visible on the new button, which enabled the documents that were supposed to created in the document set to be created at the root level (temporarily).  Then I reordered the content types, then set the non-docset content types back to not being visible.  VOILA! to my surprise that solved the problem....

Setting up an SP2013 VM on Azure, with a GUID-less DB

Image
Critical Path Training produces a number of excellent training courses, books, and free resources.   If you haven't checked out their  Inside SharePoint 2013  book, you definitely should.  It's a pretty comprehensive guide to what Developers need to know (initially) to do SP2013 Development. I typically build their VM when I first start using the next version of SharePoint and often make it my baseline for general development.   This year however I've decided to spice it up a bit and go for an install without the Configuration Wizard and a GUID-less database instance, per  Todd Klindt/Shane Young's book  because their guide is more close to an enterprise level configuration.  I also wanted install and configure it in Azure, so I can get to it wherever I am (and free up some  SSD  space on my PC). The Critical Path VM guide can be downloaded  here .  You'll need a (free) account to download the guide.  I sug...