Category: SharePoint

Office 365 Advent Calendar – 23 Bulk-updating File Extensions in SharePoint Online with PowerShell

office-365-advent-calendar

Scenario

A short while ago, I had to update a fairly large number of documents in multiple libraries in a SharePoint Online site. Problem was that their file extension was .html which doesn’t display in the browser if stored in SharePoint Online, but rather these files get downloaded upon opening. The workaround – rename them to .aspx. The following scripts does this for all .html files and renames them to .aspx

Code

$cred = Get-Credential
Connect-PnPOnline -Url "http://mytenant.sharepoint.com/sites/demo" -Credentials $cred
$ctx = Get-PnPContext
$libraries = Get-PnPlist | Where{$_.BaseTemplate -eq 101}
foreach($lib in $libraries) {
	write-host "Getting items from $($lib.Title)"
	$items = Get-PnPListItem -List $lib -Fields "Title", "FileLeafRef" | where {$_["FileLeafRef"] -like "*.html"}
	write-host "Looping through the items"
	foreach($item in $items) {
		$file = $item.File
		$ctx.Load($file)
		$ctx.Load($file.ListItemAllFields)
		$ctx.ExecuteQuery()
		write-host "Renaming file $($file.Name)"
		$newName = $file.Name -Replace "\.html",".aspx"
		Move-PnPFile -ServerRelativeUrl $file.ServerRelativeUrl -TargetUrl "$($file.ListItemAllFields['FileDirRef'])/$($newName)" -Force
	}
}

Office 365 Advent Calendar – 22 Modern and Classic Experience in SharePoint Online

office-365-advent-calendar

Earlier this year, Microsoft announced and rolled out the modern experience for lists. They didn’t stop at that, but also introduced modern pages and sites. But what are the differences to the ‘classic experiences’, so the type of lists, libraries, pages, and sites that we’ve been using now for many years? How can you switch between these two experiences? And how can you customise the modern experience items? Luckily, there’s some good guidance available from Microsoft.

First of all, it should be noted that the classic experience won’t disappear anytime soon. While Microsoft is rolling out the modern experience, the classic experience will still remain available. However, it should be noted that the functionality set between these two can be quite different. Review the links listed further below for details.

How do I switch between experiences?

For lists and libraries, please have a look at Switch the default experience for lists or document libraries from new or classic.

For modern sites and pages, the situation is a bit more different. You can’t switch a site between the classic and the modern experience. You also can’t upgrade a ‘classic’ site to a ‘modern’ site, however you can enable the corresponding capabilities to make a ‘classic’ site make use of the ‘modern’ features.

 

What are the differences between ‘classic’ and ‘modern’ lists/libraries?

This article provides some details on which functionality is currently only available in the ‘classic experience’. As you can see, there is quite a range of useful functionality that is not yet in the ‘modern experience’. Note that not all differences are listed. For example, the new smart filters are only available in modern lists. Also, existing customizations will most likely not work anymore.

 

What kind of customization possibilities do I have for ‘modern experiences’?

Have a look at this great article by Vesa Juvonen, and the other pages mentioned in it.

 

Office 365 Advent Calendar – 20 Get notified about new SharePoint Online Site Collection Administrators

office-365-advent-calendar

If your organization provides business users with the possibility to manage sites themselves by assigning them site collection administrator rights, you may want to know if they add anyone else as site collection administrator. While you could run a script regularly to retrieve a list of all site collection administrators on all sites and then compare this data with previous information, there is also an alternative that you can use. Office 365 provides you with the option to get alerted when someone gets added as a site collection administrator.

First, open the Office 365 Security & Compliance portal. Select Alerts and ‘Manage alerts’, then click on ‘Add an alert’ in the right content pane

 

Setting up the alert is fairly easy. Start by specifying a name and optionally a description. The most important setting is “Send this alert when…” where you specify which activities you want to get alerted on. Select ‘Added site collection admin’ here. Sadly, there is no way to monitor removal of site collection admins.

Lastly, specify who should be alerted, and save your alert.

Please note the following: “It can take up to 30 minutes or up to 24 hours after an event occurs for the corresponding audit log entry to be displayed in the search results.” (Search the audit log in the Office 365 Security & Compliance Center). This means that notifications are not immediate, but may take some time until the corresponding event appears in the audit logs and the alert gets triggered.

Office 365 Advent Calendar – 18 Adding a Web Part to a SharePoint Online Page with PowerShell

office-365-advent-calendar

Scenario

You’ve got a Web Part which you want to add to one, but more likely multiple web part pages in a SharePoint Online Site. Or maybe even on multiple pages across multiple sites. You could do this manually, but adding the same web part with the same configuration over and over again may not be a productive use of it. Let’s make use of PowerShell to do this!

Code

The code itself is quite simple, as the PnP PowerShell cmdlets contain a cmdlet named Add-PnPWebPartToWebPartPage. All you need is the page where you want to add the web part as well as the XML of your web part.

Let’s say you’ve got a “This SharePoint site will be archived on 31/12/2016” message which you want to add to the default.aspx page on a list of sites. You can create the Web Part with the desired message and formatting once, then export it:

Once exported, you can use the following script to add the same web part to all default.aspx pages on all sites listed in SitesToArchive.csv. The Web Part will be added to the Zone named “Left” with an index of 0, that is at the top of it:

$cred = Get-Credential
$websToUpdate = Import-Csv SitesToArchive.csv
foreach($web in $websToUpdate) {
	write-host "Connecting to $($web.Url)"
	Connect-PnPOnline -Url $web.Url -Credentials $cred
	Add-PnPWebPartToWebPartPage -ServerRelativePageUrl "default.aspx"`
	-Path "c:\users\rmodery\Desktop\ArchiveMessageWebPart.dwp" -ZoneId "Left" -ZoneIndex 0
}

 

How about wiki pages in SharePoint Online? Add-PnPWebPartToWikiPage may help you here!

Office 365 Advent Calendar – 17 Overview of the new OneDrive for Business Admin Portal

office-365-advent-calendar

At the Microsoft Ignite conference in September, it was announced that OneDrive for Business would get its own Admin Portal in Office 365. Yesterday, Microsoft finally made it available, even though it’s in Preview at the moment. See the official announcement here, and access it at https://admin.onedrive.com.

So what does it include? Some existing settings, such as configuring your sharing settings, as well as new settings like the possibility to restrict access to certain IP addresses. Here’s a detailed overview of the current status:

 

Sharing

In this section, you can control if sharing with externals is enabled, and if so, with which configuration. These are the same settings which currently exist in the SharePoint Admin Portal.

 

Sync

In the Sync section, you can define a few settings related to the OneDrive for Business client. First of all, whether user can install the client from the website. You can also define if syncing should be restricted to PCs that are joined to specific domains –  to retrieve the GUIDs you need to enter here follow these instructions. This setting is extremely helpful if you want to ensure that your users don’t use for example their personal PCs to synchronise content. Lastly, you can also restrict which file types can be synced.

 

Storage

This is a simple section – define how muich default storage is available for new users, and define how long you want to keep files in a user’s OneDrive after his account is scheduled for deletion. This setting could previously be set via PowerShell only, and allows for values between 30 and 3650 days (yes, the maximum retention period is 10 years).

 

Device access

If you want to control from which devices and locations content can be accessed, you can define specific IP addresses here or define your Intune settings.

Compliance

Lastly, the Compliance section provides you with a range of links to existing pages where you can define auditing, DLP, retention, eDiscovery, and Alerts settings.

Office 365 Advent Calendar – 15 Activating Publishing Features on SharePoint Online Sites with PowerShell

office-365-advent-calendar

Scenario

Activating SharePoint’s Publishing features can easily be done on a single site collection or site. But what if you need to activate Publishing on a hierarchy of subsites, or across multiple site collections?

Code

Once again, we’re using the PnP PowerShell cmdlets.

First some basics. The ‘main’ feature to activate is the PublishingSite feature on the Site Collection level. After you connected to a site collection (Connect-PnPOnline), you can activate it as follows:

Enable-PnPFeature -Identity f6924d36-2fa8-4f0b-b16d-06b7250180fa -Scope Site

The -Scope Site parameter is important, as the default for this parameter is set to Web, and the feature wouldn’t get activated without specifying it correctly.

Once that’s done, we can activate the PublishingWeb feature for the current site (on a Web scope):

Enable-PnPFeature -Identity 94c94ca6-b32f-4da9-a9e3-1f3d343d7ecb

Office 365 Advent Calendar – 14 Exporting SharePoint Online List/Library Details

office-365-advent-calendar

Well, this is a bit embarrassing. Yesterday, for the first time, I didn’t verify if my scheduled blog post got published properly. And yesterday, also for the first time, it didn’t get published. I made a small scheduling mistake (it’s not 2017 yet…), so the 14th December post comes a day late:

Scenario

From time to time you may need an overview of all lists and libraries in your site together with the number of items in each list/library, and when an item in it was last modified. You can easily see this information from the Site Contents page:

But there are times when this information needs to be available in Excel, which is what I’ll show you today how to retrieve:

Code

$cred = Get-Credential
Connect-PnPOnline -Url "https://mytenant.sharepoint.com/sites/demo" -Credentials $cred

#the following is required to load the corresponding list templates for each list/library
$ctx = Get-PnPContext
$templates = (Get-PnPWeb).ListTemplates
$ctx.Load($templates)
$ctx.ExecuteQuery()

Get-PnPList | select Title, @{label="Url";Expression={$_.RootFolder.ServerRelativeUrl}},`
@{label="Type";Expression={$bt=$_.BaseTemplate;$templates |`
Where{$_.ListTemplateTypeKind -eq $bt} | foreach{$_.Name}}},`
ItemCount, LastItemModifiedDate | Export-Csv c:\ListInfo.csv

And here’s the output from the script:

 

Office 365 Advent Calendar – 13 Useful Office 365 Sessions from Microsoft Ignite

office-365-advent-calendar

End of September, the Microsoft Ignite conference took place in Atlanta with hundreds of sessions across a huge rang of Microsoft products. The great news is that these sessions are available on demand for anyone to view! If you’re interested in taking them offline, have a look at the Ignite 2016 Slidedeck and Video downloader script.

Today, I’ll share with you some of my favourite sessions:

Drive productivity with OneDrive and SharePoint file collaboration

Files are at the core of the modern world. They reflect people’s and organizations’ aspirations, processes and outcomes. Making it easy to securely create and collaborate on important files such as budgets, reports, whitepapers and presentations is critical to organizational success. See all the options that Microsoft OneDrive and Microsoft SharePoint provide to enable people to work together more effectively to drive successful outcomes. We demonstrate all the possibilities available today for browser, mobile and desktop experiences and how this fits into productivity tools and essential business applications.

Why I recommend it:
 A great overview of OneDrive for Business and SharePoint and which route Microsoft is taking with them.

 

Build your intranet with Microsoft Office 365

There is a growing trend of organizations moving to the cloud to meet their intranet needs. While many organizations are running their intranets on premise, many are considering entirely cloud-based solutions or running them on platforms like Office 365. The question for many companies is “should our intranet be built with Microsoft Office 365?”

In this session, Richard Harbridge explores:
• The benefits Office 365 brings to an intranet
• Where the issues and challenges will lie
• When and how you may integrate Office 365 with your existing intranet today

Why I recommend it: Richard is a great guy and passionate presenter. He’s got a lot of experience and knows what he’s talking about. This topic here is one very close to my heart, as I’ve been working with SharePoint as an intranet platform since 2007.

 

Build business applications with Power Apps, Microsoft Flow, and Office 365

PowerApps and Flow are services for building and using custom business apps that connect to your data and work across the web and mobile – without the time and expense of custom software development. This session demonstrates how to build custom business applications, describes the vision behind PowerApps and Flow, and features key scenarios.

Why I recommend it: People have been looking for an InfoPath replacement every since it has been deprecated. While PowerApps is far from being one, it is at least the successor to InfoPath and may at some point in the future offer similar functionality. Either way, if you’re interested in forms and business processes, this is a good introduction to the latest Microsoft tools which became generally available in the meantime.

 

Improve Office 365 adoption: top 10 ways

How are organizations able to succeed with the constant change of Microsoft Office 365? Office 365 provides an incredible amount of value to individual employees, teams, departments and organizations. Much of this value is not realized immediately upon purchase or even deployment of Office 365. The value is realized as more and more users understand, adopt and embrace the technology that has been implemented. So how can organizations drive faster, sustainable and effective adoption? They perform campaigns, run activities, and take action. Join Kanwal Khipple as he shares industry leading real world experience, advice and activities that other customers are leveraging to get more from Office 365 and drive more meaningful adoption.

Why I recommend it: It’s a panel discussion by Susan Hanley, Richard Harbridge, Christian Buckley, and Kanwal Khipple! And if you do not just want to introduce some technology, but want to ensure that people use it and receive value from it, you should definitely watch this.

 

Learn about PnP and the new SharePoint Framework

Office 365 Dev and SharePoint Patterns & Practices (PnP) helps customers move forward whether building solutions for today or tomorrow. Get latest update on the provided samples, reusable components and practices. See also what the PnP team is doing to support the new Microsoft SharePoint Framework and how you can participate to this community driven initiative.

Why I recommend it: If you look at my other Office 365 Advent Calendar posts, you can see that I posted quite a good amount of samples for the PnP PowerShell cmdlets. But this is not the only thing coming from the PnP team, there’s lots more! Vesa shows you all the other awesome things, and gives some introduction on the new SharePoint Framework. If you’re a SharePoint developer, this is a session not to be missed.