Baby steps with Bash on Windows

Creating software never gets boring as the platforms, tools and techniques are always evolving. Until recently being a developer in the Microsoft world meant working with languages like C# and VB.NET, tools like Visual Studio, Windows Command Prompt and PowerShell. Starting with the Windows 10 Anniversary update we now have access to a Linux command line called Bash and a lot of the awesome tools that the Linux community have built over the years (curl, ssh etc.)

The Microsoft Store app
in Windows 10 now makes it very easy to install Bash and the first thing you need to decide is which Linux distribution (AKA distro) you want to install… I went with Ubuntu.

Here are some more details on getting bash up and running on your Windows 10 machine:

Now that you have bash, here are links that I used to answer my questions about Bash…

What are some basic bash commands and tools?

How do I install software using bash?

How do I work with files across Windows and Bash?

How do I create scripts to string command together?

What are some fun things to use in demos?

nyancat: sudo apt-get install nyancat

cowsay: sudo apt-get install cowsay

htop: sudo apt-get install htop

midnight commander: sudo apt-get install mc

Let me know if you find anything else that would be cool to use for demoing

Apps using tenant scope permissions in a local site

If you have an autohosted SharePoint app that requests tenant scope permissions and you set the target site to a local URL you might run into a problem when debugging from Visual Studio.

The certificate is added and the app deploys fine. The user is then prompted to grant the app permission but a message notifies us that the current user does not have permission to trust the app.

Sorry, only tenant administrators can add or give access to this app

So in order to grant a user “tenant administrator” rights in a local farm complete the following:

Add the account (not via a group) to the Farm Administrators role in Central Administration

Do an IISRESET after granting the permission.

When you re-deploy the app from VS the account should now be able to click the “Trust It” button.

And you’re off to the next hurdle…

Site Templates and custom Features

SharePoint 2007 allows administrators the ability to save a site as a Site Template using the Site Actions > Site Settings > Save this site as a template option. This creates an STP file that is added to the Site Templates gallery of the Site Collection. This is useful if you want to create more Sites in the Site Collection that are based on the same configuration.

Now if you look carefully at STSADM however you will notice that there is a command (addtemplate) which allows an administrator to add a Site Template to the farm template gallery. This allows you to create Site Collections based on the uploaded Site Template.

When you save a Site Template from a site that makes use of custom Features the following needs to be considered when deploying your solution:

  1. In order to create a Site Collection you need to make sure that your custom Features are deployed to the Web Application for Central Admininistration (typically hosted on the Application Server).
  2. In order to create a Sub Site you need to make sure that your custom Features are deployed to the Web Application hosting the Site Collection where you are creating your Site.

If your custom Features are not available in the environment that you are attempting to create your Site Collection or Site you will receive the following error message:

The template you have chosen is invalid or cannot be found

To troubleshoot which custom Features are causing the issue you can do the following:

  1. Change the extension of your Site Template file from STP to CAB.
  2. Open the manifest.xml file in the CAB.
  3. Find the SiteFeatures and WebFeatures nodes.
  4. Search the Features Folder* for the GUIDs listed in the above nodes.
  5. Any GUIDs missing from the Features Folder means that you have features which have not been deployed to the appropriate server.

* c:\program files\common files\microsoft shared\web server extensions\12\template\features

Alternatively download a copy of STP inspector to make troubleshooting much less tedious.

Long running jobs in SharePoint

As part of a solution that I’m putting together at the moment I had a requirement that went something like this:

We want an export button on the search results page that allows us to save all the search results to the desktop

Designing "bulk actions" like export that affect a large set of SharePoint items as a single operation is a challenge. Using a custom SharePoint timer job allows us to keep these potentially very costly operations outside of the user context.

The design follows this basic flow:

  1. User selects a number of items (from search results) to process
  2. Selected items are "tagged" for attention from the timer job
  3. User is notified that the operation is "scheduled"
  4. Timer job runs and identifies "tagged" items
  5. Items are processed
  6. Report is generated
  7. User is notified of completion