Enable ULS logging during App deployment

Troubleshooting is always afterwards, meaning you need logging information to backtrack the origin of the errors. But normally the logging level is set to default and the actual interesting data is missing from the ULS logs.

This post provides an approach to enable logging before deploying your apps and reverting to the default afterwards.

Before making changes to the ULS diagnostic settings you want to backup/export your settings. Doing this from the Central Administration is not your preferred way or you must love to copy and past a lot.


Export the diagnostic logging levels

You can easy export your settings by using PowerShell. Below a script which exports the diagnostic settings for the ULS logging levels. This script will export the logging levels to a CSV-file.

Get-SPLogLevel | Export-Csv "$($env:USERPROFILE)\Downloads\$((Get-Date).ToString("yyMMddHHmmss"))_LogLevels.csv" -NoTypeInformation

After opening the export in Excel, you get the data shown below.


Use PowerShell to get and/or update logging level

To get and/or update a particular log level via PowerShell you need to know how to scope the identity of the logging level. Once you know it, it’s pretty simple! The identifier is a combination of Area and Name.

Get-SPLogLevel -Identity "Search:General"

Change logging levels for App deployment

The general steps you want to include in your deployment scripts is based on lowering the logging for a predefined set of logging levels. Next execute the deployment and afterwards revert to the default.

  • Lower logging levels to Verbose
  • Execute deployment
  • Revert to default logging levels

Download the full PowerShell script here.

Lower the logging levels to Verbose

Below you find a script which sets a predefined set of logging levels. This set can be used as a basic for every deployment or configuration change. It is not set in stone that this is all you need, please update it to fit your needs.

Set-SPLogLevel -identity 'Search:Logging Correlation Data' -EventSeverity Verbose -TraceSeverity Verbose Set-SPLogLevel -identity 'SharePoint Foundation:Logging Correlation Data' -EventSeverity Verbose -TraceSeverity Verbose Set-SPLogLevel -identity 'SharePoint Server:Logging Correlation Data' -EventSeverity Verbose -TraceSeverity Verbose Set-SPLogLevel -identity 'SharePoint Foundation:Configuration' -EventSeverity Verbose -TraceSeverity Verbose Set-SPLogLevel -identity 'SharePoint Foundation:Database' -EventSeverity Verbose -TraceSeverity Verbose Set-SPLogLevel -identity 'SharePoint Foundation:Feature Infrastructure' -EventSeverity Verbose -TraceSeverity Verbose Set-SPLogLevel -identity 'SharePoint Foundation:General' -EventSeverity Verbose -TraceSeverity Verbose Set-SPLogLevel -identity 'SharePoint Foundation:Timer' -EventSeverity Verbose -TraceSeverity Verbose Set-SPLogLevel -identity 'SharePoint Foundation:Topology' -EventSeverity Verbose -TraceSeverity Verbose Set-SPLogLevel -identity 'SharePoint Foundation:Upgrade' -EventSeverity Verbose -TraceSeverity Verbose Set-SPLogLevel -identity 'SharePoint Foundation:PowerShell' -EventSeverity Verbose -TraceSeverity Verbose Set-SPLogLevel -identity 'SharePoint Foundation:App Deployment' -EventSeverity Verbose -TraceSeverity Verbose Set-SPLogLevel -identity 'SharePoint Foundation:App Management' -EventSeverity Verbose -TraceSeverity Verbose Set-SPLogLevel -identity 'SharePoint Foundation:App Marketplace' -EventSeverity Verbose -TraceSeverity Verbose Set-SPLogLevel -identity 'SharePoint Foundation:Application Authentication' -EventSeverity Verbose -TraceSeverity Verbose Set-SPLogLevel -identity 'SharePoint Foundation:Authentication Authorization' -EventSeverity Verbose -TraceSeverity Verbose Set-SPLogLevel -identity 'SharePoint Foundation:CSOM' -EventSeverity Verbose -TraceSeverity Verbose Set-SPLogLevel -identity 'SharePoint Foundation:CSOM Api' -EventSeverity Verbose -TraceSeverity Verbose Set-SPLogLevel -identity 'SharePoint Foundation:App Hosting Quota Management' -EventSeverity Verbose -TraceSeverity Verbose Set-SPLogLevel -identity 'SharePoint Foundation:App Monitoring' -EventSeverity Verbose -TraceSeverity Verbose Set-SPLogLevel -identity 'SharePoint Foundation:App Auth' -EventSeverity Verbose -TraceSeverity Verbose Set-SPLogLevel -identity 'SharePoint Portal Server:Runtime' -EventSeverity Verbose -TraceSeverity Verbose Set-SPLogLevel -identity 'SharePoint Portal Server:Long Running Operation' -EventSeverity Verbose -TraceSeverity Verbose Set-SPLogLevel -identity 'SharePoint Server:General' -EventSeverity Verbose -TraceSeverity Verbose Set-SPLogLevel -identity 'SharePoint Server:Setup and Upgrade' -EventSeverity Verbose -TraceSeverity Verbose Set-SPLogLevel -identity 'SharePoint Server:Database' -EventSeverity Verbose -TraceSeverity Verbose

Revert back to the default logging levels

Revert the logging levels to the default, after executing the deployment or configuration changes.


PowerShell x64 vs x86: set execution policy when using Visual Studio post build events

Running PowerShell scripts in the Post build events within a Visual Studio project? Getting errors telling you “running scripts is disabled on this system”?

Visual Studio Output window showing PowerShell execution error

While working on Office 365 Developer Patterns and Practices (PnP) solution OfficeDevPnP.PowerShell Commands I had troubles with building my solution. Visual Studio uses PowerShell x86 in the background instead of my default PowerShell which uses the x64 version.

Check PowerShell version: x64 versus x86

By running the following you can check the current version. Download the PowerShell function from Check-PSVersion.ps1

function Check-PSVersion { if ([System.IntPtr]::Size -eq 4) { # When equal to 4, then x86 Write-Host "Running x86 PowerShell session" } else { # When equal to 8, then x64 Write-Host "Running x64 PowerShell session" } } Check-PSVersion

Where to find the PowerShell executable for both x64 and x86

The x64 version of PowerShell (Windows 8.1) can be found under:


The x86 version of PowerShell (Windows 8.1) can be found under:


Change execution policy to use PowerShell in Visual Studio

Now we know we have two versions of PowerShell we can change the execution policy for the x86 version of PowerShell. Start the "C:\Windows\syswow64\WindowsPowerShell\v1.0\powershell.exe" with “Run as administrator”. Now change the execution policy accordantly.

Set-ExecutionPolicy Unrestricted

Show storage overview for site-collections with PowerShell

PowerShell is very powerful and helps you to quickly get different views on your SharePoint environment. The Usage class can be used to retrieve Storage information for a particular site-collection. Combining this into a PowerShell script provides an overview of storage sizing for your personal storage sites (My Sites) for example.

In this example all My Sites are located within the namespace http://my.contoso.com. When querying the My Sites I’m using this as input. After the basic query I transform the output to get the report.

The first query can be used for the numbers based on megabytes (MB). I’m using the System.Math.Round() method to transform the output based on custom tables in PowerShell.

Get-SPSite -Limit ALL | ?{$_.Url -like "*my.contoso.com*"} | Format-Table Url, @{Expression={[math]::round($_.Usage.Storage/1MB, 3)};Label="Storage"} -AutoSize

The output is shown below.

PowerShell console, output storage query

When I change the formatting for better readability you get the following query. The column Storage is displayed based on string formatting.

Get-SPSite -Limit ALL | ?{$_.Url -like "*my.contoso.com*"} | Format-Table Url, @{Expression={($_.Usage.Storage/1MB).ToString("#,###.000 MB")};Label="Storage"} -AutoSize

This will impact the column Storage shown in the output below.

PowerShell console, output storage query with string Formatting

Enjoy! Have fun with PowerShell.

How to: Detect the installed SKU of SharePoint with PowerShell

Do you need to know which SharePoint SKU or edition is installed on your server? Are you sure your product is not running the trial version? Do you need SharePoint 2010/2013 SKU and/or patch level information from your customer or IT department? This article provides you an easy to use PowerShell script which checks the installed products on a server and outputs the version (patch level).

You can use the Get-SPEdition PowerShell script as is. Simply run the script or use the Functions and call Get-SPEdition. Using the PowerShell scripts results in the following output.

Windows PowerShell: out Get-SPEdition

The script reads the registry to retrieve the installed versions. This information is located in below the “HKLM:software\Microsoft\Shared Tools\Web Server Extensions\15.0\WSS\InstalledProducts” path. Every GUID represents a SKU.

$products = @{ "BEED1F75-C398-4447-AEF1-E66E1F0DF91E" = "SharePoint Foundation 2010"; "1328E89E-7EC8-4F7E-809E-7E945796E511" = "Search Server Express 2010"; "B2C0B444-3914-4ACB-A0B8-7CF50A8F7AA0" = "SharePoint Server 2010 Standard Trial"; "3FDFBCC8-B3E4-4482-91FA-122C6432805C" = "SharePoint Server 2010 Standard"; "88BED06D-8C6B-4E62-AB01-546D6005FE97" = "SharePoint Server 2010 Enterprise Trial"; "D5595F62-449B-4061-B0B2-0CBAD410BB51" = "SharePoint Server 2010 Enterprise"; "BC4C1C97-9013-4033-A0DD-9DC9E6D6C887" = "Search Server 2010 Trial"; "08460AA2-A176-442C-BDCA-26928704D80B" = "Search Server 2010"; "84902853-59F6-4B20-BC7C-DE4F419FEFAD" = "Project Server 2010 Trial"; "ED21638F-97FF-4A65-AD9B-6889B93065E2" = "Project Server 2010"; "926E4E17-087B-47D1-8BD7-91A394BC6196" = "Office Web Apps 2010"; "35466B1A-B17B-4DFB-A703-F74E2A1F5F5E" = "Project Server 2013"; "BC7BAF08-4D97-462C-8411-341052402E71" = "Project Server 2013 Preview"; "C5D855EE-F32B-4A1C-97A8-F0A28CE02F9C" = "SharePoint Server 2013"; "CBF97833-C73A-4BAF-9ED3-D47B3CFF51BE" = "SharePoint Server 2013 Preview"; "B7D84C2B-0754-49E4-B7BE-7EE321DCE0A9" = "SharePoint Server 2013 Enterprise"; "298A586A-E3C1-42F0-AFE0-4BCFDC2E7CD0" = "SharePoint Server 2013 Enterprise Preview"; "D6B57A0D-AE69-4A3E-B031-1F993EE52EDC" = "Microsoft Office Online"; "9FF54EBC-8C12-47D7-854F-3865D4BE8118" = "SharePoint Foundation 2013" } $registryPath = "HKLM:software\Microsoft\Shared Tools\Web Server Extensions\$((Get-SPFarm).BuildVersion.Major).0\WSS\InstalledProducts" Get-RegistryKeyPropertiesAndValues -path $registryPath | ForEach-Object { Write-Host "Installed product: $($products.Get_Item($_.value)) (SKU ID: $($_.value))" } Write-Host "Installed version: $((Get-SPFarm).BuildVersion)"

With a little help from the Scripting Guy (Ed Wilson) and two MSDN articles I build the script. Enjoy!

Download: Get-SPEdition.ps1


Merge log files when troubleshooting a multi server SharePoint farm

Even after working with SharePoint for a while you find new features. The Merge-SPLogFile cmdlet is one of them.

This cmdlet retrieves all ULS log entries from all servers in the farm and creates a one new log file. You can use the ULS viewer for further slicing and dicing the log file for more details.

Use the cmdlet with additional parameters, otherwise it could become a large operation resulting in a large file. Use like “Merge-SPLogFile -Path "C:\Logs\FarmMergedLog.log" -Overwrite -StartTime "06/09/2008 16:00" – EndTime "06/09/2008 16:15"” is very useful.

Very use full for troubleshooting! Why I’ve missed this one, I don’t know…

Developing hybrid SharePoint apps that run on-premise and in the cloud – ESPC 2014

My session at the European SharePoint Conference (#ESPC14) was around developing hybrid apps with the SharePoint App Model. Below you can find the slide deck and PowerShell scripts I used during the demo.

Before you start building hybrid apps who are depending on the authentication done by Azure Control Services (ACS) you need to setup a trust between your on-premise farm and ACS.

  1. Replace the default STS certificate and reboot machine afterwards (Replace-STSCertificate.ps1)
  2. Install Microsoft Online Services Sign-In Assistant for IT Professionals RTW (64-bit), http://www.microsoft.com/en-us/download/details.aspx?id=41950
  3. Install Microsoft Online Services Module for Windows PowerShell (64-bit), http://go.microsoft.com/fwlink/p/?linkid=236297
  4. Run script to connect on-premise SharePoint farm to ACS (Connect-SPFarmToAAD.ps1)

Some important side notes:

  • When replacing the STS certificate, all current trusts who are depending on the STS become invalid. Meaning you have to recreate your existing Trusted Security Token Issuers (Install-TrustedSecurityTokenIssuer.ps1 & Remove-TrustedSecurityTokenIssuer.ps1)
  • Ensure you are using the RTW version of Microsoft Online Services Sign-In Assistant instead of the BETA (which is linked in the TechNet article)

Download PowerShell scripts.

Scripts originate from How to: Use an Office 365 SharePoint site to authorize provider-hosted apps on an on-premises SharePoint site (http://msdn.microsoft.com/en-us/library/office/dn155905(v=office.15).aspx), I don’t own the scripts but only provide them for easy of use.

Error installing SharePoint 2013 SP1 bits on Virtual Machine

As part of creating a developer virtual machine you need to install the SharePoint 2013 bits. Now with the release of Service Pack 1 you can install both SharePoint 2013 and Service Pack 1 in one run.

But when I installed the software bits an exception was raised.

Problem signature:
  Problem Event Name:    OfficeClassicSetup
  SETUP EXE VERSION:    15.0.4454.1000
  SETUP DLL VERSION:    15.0.4569.1503
  ERROR CODE:    1603
  MSI HRESULT:    Unspecified
  OS Version:    6.3.9600.
  Locale ID:    1043

After digging around on the internet and trying different solutions the failing of the installation seems to be related to the CPU count. After increasing the number of virtual processors on the VM to 2 processors and re-running the prerequisites installer and SharePoint 2013 installer everything worked like a charm.

Solution steps:

  1. Increase virtual processor count to at least 2
  2. Re-run SharePoint 2013 prerequisites installer
  3. Re-run SharePoint 2013 installer

Develop, Build, Package and Deploy Apps for Office 2013 with Visual Studio 2013–European Office 365 Connect

On April 1st and 2nd in Haarlem (The Netherlands) the first European Office 365 Connect took place. Speakers from over the world (like Dan Holme, Seb Matthews, Marc Reguera and many more) visited Haarlem and did sessions related to Office 365.

I’ve done a session about Apps for Office together with Visual Studio 2013. This was a kind of follow-up session for “The New SharePoint Online Apps – Napa in Action” from Patrick Lamber. You can find my slide deck below.

The demo was around building a Wikipedia Task Pane app which leverages the Wikipedia API for searching Wikipedia. Below a screenshot of the Task Pane App for Office inside the Word 2013 (desktop) client.

Wikipedia Task Pane app inside Word 2013 client

Once the app was done it’s deployed to Windows Azure via a Web Deploy package and the XML manifest is made available to end-users to consume from the Corporate Catalog (hosted in SharePoint Online). After configuring the Office client the Corporate Catalog is available from within Word, Excel, PowerPoint.

Apps for Office catalog in Word (desktop) client

Download the demo sources here: http://1drv.ms/1pTuGx9

SharePoint Online Tenant URLs

Setting up your Office 365 environment and looking for the entry URLs? Below you can find the URLs related to your company SharePoint Online tenant.

Commonly used URLs for a SharePoint Online tenant:

Other URLs related to Office 365:

Service Pack 1 for SharePoint 2013 and more… [updated]

A bit more than a year ago Microsoft released SharePoint 2013 (RTM: 10/11/2012, GA: 2/28/2013). A couple of days ago Office 2013 Service Pack 1 (2/25/2014) is released, which include Office 2013, SharePoint 2013 and Exchange Server 2013.

With regards to SharePoint the following links are useful:

  • SharePoint Foundation 2013
  • SharePoint Server 2013
  • Project Server 2013
  • Office Web Apps 2013
  • Duet Enterprise
    • Duet Enterprise for Microsoft SharePoint and SAP Server 2.0 Service Pack 1 (SP1), KB 2817426

A more in-depth article on updates included in Service Pack 1 is found on the Microsoft Engineering Team blog, check out Announcing the release of Service Pack 1 for Office 2013 and SharePoint 2013.

Don’t forget to update your Workflow Manager 1.0 with Cumulative Update 1.0 for both Workflow Manager and Service Bus.

[23/04 update: SharePoint 2013 Service Pack 1 was pulled by Microsoft. Yesterday they re-released Service Pack 1, check this post for more information http://blogs.technet.com/b/stefan_gossner/archive/2014/04/22/sp1-for-sharepoint-2013-has-been-rereleased.aspx]


Get every new post delivered to your Inbox.

Join 37 other followers