All posts by Jason Warren

Get a list of SharePoint sites that allow anonymous authentication

For administrators who manage (usually) public-facing SharePoint farms, it’s good to keep tabs on the sites that allow anonymous users. Configuring anonymous access is a multi-step process — there are web application settings, site settings, and permissions. Although there is a lot of configuration, it’s easy to see which sites allow anonymous authentication using the SPWeb.AnonymousState site-level flag. Using this property we can write a short PowerShell script to list out all the sites in the farm and display whether or not they allow anonymous authentication.

SharePoint 2013 and SharePoint 2010

For SharePoint 2010, SharePoint 2013, and presumably future versions of SharePoint, getting this list is simple using the Get-SPSite cmdlet which can be used to list every site collection in the farm:

$sites = Get-SPSite -Limit All
foreach ($site in $sites) {
	$site.AllWebs | Select Url, AnonymousState

The output will look like something like this:

Url                                         AnonymousState
---                                         --------------                                 Disabled                    Disabled                                      On                                On                              On                              On                               On

SharePoint 2007

If you have PowerShell installed on a server in the farm (you really should), you can use PowerShell to build this handy report just it takes a bit more effort:

$farm = [Microsoft.SharePoint.Administration.SPFarm]::Local
$websvcs = $farm.Services | where -FilterScript {$_.GetType() -eq [Microsoft.SharePoint.Administration.SPWebService]}
$webapps = @()
foreach ($websvc in $websvcs) {
	foreach ($webapp in $websvc.WebApplications) {		
		foreach ($site in $webapp.Sites) {
			$Site.AllWebs | Select Url, AnonymousState

The output will look look the same as with later versions of SharePoint:

Url                                          AnonymousState
---                                          --------------                                 Disabled                    Disabled                         On                   On           On

(HT to Gary Lapointe for the code to get the web applications in a SharePoint 2007 farm using PowerShell: Getting an SPWebApplication object using PowerShell.

Share Button

Add and remove MIME types from SharePoint (PowerShell)

Petro Margaritis has a PowerShell script for adding a MIME type to a SharePoint web application: Setting Trusted IIS MIME Types In SharePoint using PowerShell. I modified it to allow you to remove the MIME type if it already exists:

Write-Host "This script will check if a particular MIME Type is excluded from the AllowedInlineDownloadedMimeTypes list when STRICT Browser File Handling Permissions are set on the Web Application" -foregroundcolor Darkcyan
$webAppRequest = Read-Host "What is the name of your Web Application? i.e. http://<serverName>"
$webApp = Get-SPWebApplication $webAppRequest
$mimeType = Read-Host "Which MIME Type would you like to confirm is included in the AllowedInlineDownloadedMimeTypes list for $webApp ? i.e. application/pdf"
If ($webApp.AllowedInlineDownloadedMimeTypes -notcontains "$mimeType")
    write-host "$mimeType does not exist in the AllowedInlineDownloadedMimeTypes list" -foregroundcolor Yellow
    $addResponse = Read-Host "Would you like to add it? (Yes/No)"
    if ($addResponse -contains "Yes")
        Write-Host "The MIME Type ' $mimeType ' has now been added" -foregroundcolor Green
        $iisresponse = Read-Host "This change requires an IIS Restart to take affect, do you want to RESET IIS now (Yes/No)"
        if ($iisResponse -contains "Yes")
            Write-Host "IIS has now been reset" -foregroundcolor Green
            Write-Host "IIS has not been reset, please execute the IISRESET command at a later time" -foregroundcolor Yellow
        Write-Host "The MIME Type ' $mimeType ' was not added" -foregroundcolor Red
    Write-Host "The MIME Type ' $mimeType ' already exists in the AllowedInlineDownloadedMimeTypes list for this Web Application" -foregroundcolor Yellow
	$addResponse = Read-Host "Would you like to remove it? (Yes/No)"
    if ($addResponse -contains "Yes")
        Write-Host "The MIME Type ' $mimeType ' has now been removed" -foregroundcolor Green
        $iisresponse = Read-Host "This change requires an IIS Restart to take affect, do you want to RESET IIS now (Yes/No)"
        if ($iisResponse -contains "Yes")
            Write-Host "IIS has now been reset" -foregroundcolor Green
            Write-Host "IIS has not been reset, please execute the IISRESET command at a later time" -foregroundcolor Yellow
        Write-Host "The MIME Type ' $mimeType ' was not removed" -foregroundcolor Red

Share Button

Vancouver SharePoint Summit 2014: Session Picks

Here are the sessions I’m looking forward to. I don’t know if I’ll be able to make them all, but thought it would be nice to post this up. If you have any suggestions, feel free to let me know.

Day 1

9:00 AM – 10:15 AM 1.3 Salon B Developing for Office 365 – Lessons Learned from a SharePoint Developer – Mike Jensen

10:30 AM – 11:45 AM 2.2 Salon B Measuring Success in Enterprise Social – Naomi Moneypenny

12:45 PM – 2:00 PM I’m torn between 3.0 To App or Not to App by Yaroslav Pentsarskyy in Salon E, and 3.1 Building An Enterprise Search Strategy with SharePoint 2013 by Joel Oleson in Salon F.

2:15 PM – 3:45 PM 4.1 Salon F Tuning SQL Server 2012 for SharePoint 2013: What Every SharePoint Consultant Should Know – Serge Luca and Isabelle Van Campehoudt

3:45 PM – 5:00 PM 5.1 Salon D The Tipping Point Between On-Premises and the Cloud – Robert LaMear

Day 2

9:00 AM – 10:15 AM 6.0 Tuscany Secure SharePoint Development – Eli Robillard

10:30 AM – 11:45 AM 7.2 Salon B Classificiation and eDiscovery with Exchange and SharePoint 2013 – Chris McNulty

1:00 PM – 2:15 PM 8.0 Salon B The Value of Tribal Knowledge and Strategies to Increase Adoption – Kanwal Khipple

2:20 PM – 3:35 PM 9.3 Salon F Content Search Web Part – Get it All in One Place and Style it! – Benjamin Niaulin

3:50 PM – 5:05 PM 10.0 Salon E Multi-Factor Authenitcation for SharePoint On-Premise and Cloud – Liam Cleary

Day 3

8:30 AM – 9:45 AM 11.0 Salon B Under the Hood: SharePoint Server 2013 Search – Jason Warren. I would totally go to this even if it wasn’t me presenting it. Highly recommended.

9:50 AM – 11:05 AM 12.0 Tuscany Enterprise Social: What is the real value to the business? – Roven Gotz

11:05 AM – 11:30 AM Salon A — I’ll be in the expo answering questions if this is the sort of thing you’re in to.

11:30 AM – 12:45 PM 13.2 Salon E Using workflows and SharePoint to improve Davis LLP’s hiring process – Adam Pucek and Juli Ramløse-Svendsen

1:45 PM – 3:00 PM 14.1 Salon D Customizing Search Results with Result Types, Resource Sources, and Display Templates – Shereen Qumsieh

Share Button

Script: Clearing the SharePoint configuration cache on all servers in the farm

Need to clear the configuration cache on all of your SharePoint servers but don’t want to take the time to do it manually?

If you’ve configured PowerShell Remoting between the farm servers and are logged onto any server in the farm with an administrative account, you can run this script to automate this process.

Note the folder is for SharePoint 2010 and SharePoint 2013.

I borrowed the bulk of the clearing code from Thomas Bernhard’s blog post Clear SharePoint Config Cache with PowerShell and wrapped it in a script block so we can run it remotely.

Save the code below in a .ps1 and run it from one of the SharePoint servers in the farm in an elevated PowerShell window (you could also just paste it into the PowerShell window if you’re into that sort of thing).

#Script block for stopping the timer service
$sb_stop = {
	Write-Output "`t$($env:computername)"
	Stop-Service -Name "SPTimerV4"

#Script block for starting the timer service
$sb_start = {
	Write-Output "`t$($env:computername)"
	Start-Service -Name "SPTimerV4"

#Script block for finding and clearing the configuration cache
$sb_cache = {
	Write-Output "`t$($env:computername)"
	$folders = Get-ChildItem "C:\ProgramData\Microsoft\SharePoint\Config"
	foreach ($folder in $folders) {
		$items = Get-ChildItem $folder.Fullname -Recurse
		foreach ($item in $items) {
			if ($item.Name.ToLower() -eq "cache.ini") {
				$cachefolder = $folder.FullName
			} #if
		} #foreach item
	} #foreach folder
	Write-Output "`tDeleting xml..."	
	$cachefolderitems = Get-ChildItem $cachefolder -Recurse
	foreach ($cachefolderitem in $cachefolderitems) {
		if ($cachefolderitem -like "*.xml") {
		} #if
	} #foreach
	Write-Output "`tResetting cache ini..."
	$a = Get-Content $cachefolder\cache.ini
	$a = 1
	Set-Content $a -Path $cachefolder\cache.ini

} # sb

Add-PSSnapin Microsoft.SharePoint.PowerShell
$servers = Get-SPServer | where {$_.Role -eq "Application"} | select -ExpandProperty Address
Write-Output "Servers in the farm: $servers"

#Stop timer
foreach ($server in $servers) {
	Write-Output "Stopping Timer Service on $server"
	Invoke-Command -Computername $server -ScriptBlock $sb_stop
	Write-Output " "

#Clear cache
foreach ($server in $servers) {
	Write-Output "Clearing configuration cache on $server"
	Invoke-Command -Computername $server -ScriptBlock $sb_cache
	Write-Output " "

#Start Timer
foreach ($server in $servers) {
	Write-Output "Starting Timer Service on $server"
	Invoke-Command -Computername $server -ScriptBlock $sb_start
	Write-Output " "

The output will look something like this:

Share Button

“Do you also want to save changes to the document template?”


You’ve created a Word document using a custom .dotx template. Every time you go to save the document or exit Word you are prompted to save a document template, even though you have not made any changes to the template and in some cases the document.

Doyouwanttosavechangestothedocumenttemplate WanttosaveyourchangestoTemplate


Word 2013


There is a Send to Bluetooth COM add-in loaded. You are likely not using this.


Disable the Send to Bluetooth COM add-in.

  1. Open Word using an account that has administrative access to the computer.
  2. In Word click FileOptions. The Word Options window appears.
  3. In the left navigation, select Add-Ins.  Note the Send to Bluetooth COM add-in.


  1. At the bottom, select manage COM Add-ins and click Go… The COM Add-Ins window opens. Note the Send to Bluetooth add-in is available and checked.
  2. Uncheck the Send to Bluetooth add-in


  1. Click OK. Exit Word (save your documents as necessary)
  2. Open Word and make sure the Send to Bluetooth  COM add-in is no longer loaded. Follow steps 1-3


You should now be forever free of this annoying error.

This one was bugging me for a while. Thanks go out to user grantmo in this forum thread Disable “do you also want to save changes to the document template?” harassalog.

Share Button

Link Roundup 2

Here is another collection of recent (to me) links that have interested me enough to copy them into a blog post and post on the internet for all to see.

So OneNote is now free*.
* A limited version is now free for personal use, school users, Mac users, mobile users. Additional features via Office 365 are available for additional cost. Not clear how this affects the OneNote 2013 product that ships with office and asks for a product key.

SQL Server 2014 has been released to manufacturing which of course means the ISO has been copied into everyone’s MSDN and VL downloads . Wait, just checked and I don’t see it yet. Maybe someone still has to burn and rip it first. The interesting thing about this release is (in my experience) most customers are still planning their upgrade to SQL Server 2012. Now we wait to find out about support for SharePoint.

Finally, Google must have had someone attend SPC14 or maybe they watched all the videos and read all the twitter feeds. Microsoft announced awesome pricing for OneDrive and then last week Google Drive decided to lower prices to the point where they must be losing money on disk. $99/year for 10 TB of space?! Why do I even buy hdds anymore? I just did a cursory search for hard drives and the going rate (at this moment, in Canada) appears to be about $100 per 2 TB, or $500 for 10 TB.

To put this into perspective, let’s compare the Onedrive and Google Drive services:

OneDrive Google Drive
7 GB – free 15 GB – free
add 50 GB – $25/year Google doesn’t have time for 50 GB increments
add 100 GB – $50/year 100 GB $1.99/year
add 200 GB – $100/year 200 GB probably $4/year
1 TB $500/year (I’m guessing) 1 TB $9.99/year
10 TB – $5,000/year (who knows) 10 TB $99.99/year
Did you hear you can have SPO site collections that are 1 TB? for each additional 10 TB add $100

The hard drive, as they say, is now in Microsoft’s tower.

Share Button

New-SPEnterpriseSearchServiceApplication : Value cannot be null.

Got this exception when creating a search service application in a multi-server farm:

New-SPEnterpriseSearchServiceApplication : Value cannot be null.

Parameter name: indexLocation

Found the resolution in this TechNet forum post: SharePoint 2013 (RTM) Powershell New-SPEnterpriseSearchApplicationService error about non-existent “indexlocation” parameter ??

The solution in my case wasn’t the accepted answer, rather the answer from iftvio suggesting to start the search and query service instances. This answer was counter-intuitive to me because I was running the script from a server that wasn’t part of the search topology.

Let me explain.


In this particular farm, I had the search components dedicated to a specific server. I was running the script from another server in the farm. In my scripts I start the search and query instances on the servers specified in a configuration file. Since the server I was running the scripts from wasn’t a search server it wasn’t in the list of servers on which to start the service instances. It turns out though, that New-SPEnterpriseSearchServiceApplication expects these service instances to be running on the current server.

To start the instances, use Start-SPEnterpriseSearchServiceInstance and Start-SPEnterpriseSearchQueryAndSiteSettingsServiceInstance

In the end my topology is what I expected, I just stopped the service instances once I was done configuring search.

Summary: When running New-SPEnterpriseSearchServiceApplication make sure the server is running the search and query service instances.

Share Button

Link Roundup 1

Here are some interesting links I’ve come across. Consider this a test of a future recurring feature.

A lot happened at the SharePoint Conference 2014 last week. I wasn’t there, though between Yammer and Twitter it felt like Vegas here in the -20C land that is Canada.

Looking for session slides from SharePoint Conference 2014? Check out the external Yammer’s uploaded files! Videos and demos should be realeased in about a month.

Lots of great videos from SPC14 over at channel9

Rackspace released the very addictive Fanatiblaster game based on their fantatical support. I know it’s totally based on real life because every SharePoint administrator carries a dart gun to shoot folders and SharePoint sites. One of the neat things about it is @ShareP911 will tweet out anytime someone beats the high score.

If you’re using CredSSP for PowerShell remoting, know that on Windows versions earlier than Windows Server 2012 R2 and Windows 8.1 that the server you connect to stores your username and password in plain text! Check out Accidental Sabotage: Beware of CredSSP over at PowerShell Magazine

Did you know you can now get SharePoint ULS logs from SharePoint Online using CSOM?

Creating a new Office Web Apps farm on Windows Server 2008 R2 SP1 throws an exception “New-OfficeWebAppsFarm : The operation failed. The server did not meet the following prerequisites: – Windows Update KB2592525 must be installed.” Then, when you try to install the update you get the error “This update is not applicable to your computer.” To resolve this wonderful trick to logic, check out this great post courtesy of Markus Nöbauer: Office Web Apps Server – KB2592525 Installation failed

Share Button

Rename SQL Server

The other day I installed SQL Server on a VM that I had cloned from another machine. I accidentally forgot to rename the server before installing SQL Server.

After renaming the computer to the correct name, there are additional steps needed to rename the server within SQL Server:

1. Open SQL Server Management Studio or your prefered SQL management tool.

2. Execute the following query to see if the name is correct:

select @@servername

If this returns the correct server name, you’re done. Likely it wont.

3. Execute the sp_dropserver stored proceedure:

sp_dropserver 'OLDSERVERNAME'

4. Add the correct name with the sp_addserver stored procedure:

sp_addserver 'NEWSERVERNAME', local

5. Restart the instance’s SQL Server database engine service using the services.msc console, NET, or Restart-Service PowerShell cmdlet.

6. Query the instance again to verify it is the correct server name.

select @@servername
Share Button

New-SPProfileServiceApplication -MySiteManagedPath documentation bug

Hot on the heels of my previous post, New-SPProfileServiceApplication -SiteNamingConflictResolution documentation bug, the -MySiteManagedPath parameter also has inconsistent documentation with the actual cmdlet in the wild.

[Note for reference this applies at the time of this writing to SharePoint Server 2013 with the March 2013 PU + December 2013 CU, farm buildversion 15.0.4551.1508]

TechNet defines the MySiteManagedPath parameter like this:

Parameter Required Type Description
MySiteManagedPath Optional System.String Specifies the managed path where personal sites will be created.The type must be a valid URL, in the form http://server_name.

And Get-Help New-SPProfileServiceApplication -Full like so:

-MySiteManagedPath <SPPrefixPipeBind>
    Specifies the managed path where personal sites will be created.

    The type must be a valid URL, in the form http://server_name.

    Required?                    false
    Position?                    Named
    Default value
    Accept pipeline input?       True
    Accept wildcard characters?  false

Both documentation references say you need to provide a valid URL. Of course, you’re providing a managed path so a better example would be something like “http://server_name/managedpath”.

When you specify a URL the cmdlet will throw a Microsoft.SharePoint.PowerShell.SPCmdletPipeBindException with the message:

Cannot find an SPPrefix object with Name: http://server_name/managedpath

What the cmdlet really wants is the actual name of the managed path. The cmdlet runs as expected when you give it a managed path name (that exists!) instead of a URL.

For example, say you have a My Sites web application http://mysites and you’ve created a Wildcard Inclusion managed path called “personal”.

The documentation says to do this (incorrect):

New-SPProfileServiceApplication ... -MySiteManagedPath "http://mysites/personal"

Instead give it the name of the managed path like this (correct):

New-SPProfileServiceApplication ... -MySiteManagedPath "personal"
Share Button