PowerShell DSC for SharePoint

I stopped the work on my DSC modules for SharePoint (xSharePointAdministration) some time ago because the PowerShell team was working on the xSharePoint module. The module has now reached Version 1.0 and was renamed to SharePointDSC. The module is already pretty mayor and can be used to deploy SharePoint 2013 and SharePoint 2016. It supports PowerShell 4.0 and 5.0. I already started using it in some customer projects. It’s not yet perfect – but what the PowerShell team does is really “Open Development” and not just “Open source”. I contributed the xSPFarmSolution resource, the version parameter for the xFeature resource … Continue reading PowerShell DSC for SharePoint

Use SonarLint to work on your technical debt in Visual Studio

SonarQube is a really great solution to monitor and track your technical debt over time. But wouldn’t it be great if the developer could already see in Visual Studio the impact that his commit will have to the sonar dashboard? If you use Visual Studio 2015 and the C# Plugin for SonarQube you can do this with the extension SonarLint. The extension depends on the latest version of the C# Plugin – so make sure that you have the latest version (5.2) installed. In Visual Studio install the extension in the “Extensions and Updated” dialog. This adds a new Tile ‘SonarQube’ … Continue reading Use SonarLint to work on your technical debt in Visual Studio

Setup SonarQube in Azure VM

If you have installed and integrated SonarQube once in TFS 2012 you know it was really painful. But a lot of things have changed and now it’s really easy to setup a new SonarQube instance in Azure and integrate it into you build process and in Visual Studio. I did it this week and it was really fast and straight forward. Setup a machine in Azure I wanted to have a machine for trainings and demos. That’s why I decided to use SQL Server 2014 on Windows 2012 R2. Like this I can turn the machine on and of easily. … Continue reading Setup SonarQube in Azure VM

ALM Days 2016 in Köln

In einem Monat ist es soweit: die ALM Days finden dieses Jahr in Köln am 13. und 14. April statt. Wie jedes  Jahr geht es hier rund um die Themen Application Lifecycle Management, agile Entwicklung und natürlich DevOps. Als Speaker sind wieder viele Experten von Microsoft aus Deutschland und den USA und viele meiner MVP Kollegen. Die Anmeldung ist noch offen. Wer sich also bisher noch nicht angemeldet hat, kann das jetzt noch tun. Jetzt anmelden Die ALM Days sind für mich eine der besten Veranstaltungen im Jahr. Man kann sehr gut kontakte Pflegen und bekommt wirklich immer das aktuellste … Continue reading ALM Days 2016 in Köln

Release management trial license has expired

The license of the Release Management Server at one of my client expired multiple times. This time I was really sure that I had installed the correct version from MSDN. When I looked around I found the answer on msdn. As it turned out the problem is not, that the license had expired. The user under which the application pool is running has to load a user profile to read the license. This can be configured in iis. Continue reading Release management trial license has expired

Use Pester to author your PowerShell scripts

Pester is a great module for testing your PowerShell scripts and modules. It has great mocking support, a test drive for setting up isolated files and supports a lot of assertions. Since the importance of PowerShell growths, testing your scripts is a must.

This is part 2 of the series “Develop next level PowerShell with Visual Studio and Pester”. It assumes that you have a Visual Studio solution with a basic Pester Test in GitHub.

Post Content
Part 1: Develop next level PowerShell with Visual Studio and Pester In this post I focus on creating the project in Visual Studio and interacting with a source control system like git.
Part 2: Use Pester to author your PowerShell scripts using TDD/BDD This post focuses on writing PowerShell scripts or modules using Pester as a TDD/BDD framework.
Part 3: Run your Pester tests in a VSTS build In this post I show you how you can run you tests in a continuous integration build and display the build status with a badge in your repository.

 

Pester basics

If you create a new test in Visual Studio, it looks like this:

Describe "PowerShellTest1" {
    Context "Exists" {
        It "Runs" {
        }
    }
}

As you can see you have three levels:

Describe: This is the name of the test displayed in test explorer. It is not ONE test in the test results. It’s more a container scope for many tests that executes as a unit.

Context: Like “Describe” the Context is a container for tests. You can mock functions or have test files in the scope of a context.

It: “It” is the actual test. You add an assertion here to test the state of your system. “It” is also a scope for mocking like context.

You can use these elements to structure your tests in a BDD style after the GivenWhenThen pattern.

$project = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace(".Tests", "")
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".tests.", ".")
. "$project\$sut"

Describe "AnswerToUltimateQuestion" {
    Context "Given an enormous supercomputer named Deep Thought, when we ask the ultimate question about life, the universe, and everything" {
        It "should return 42" {
			       AnswerToUltimateQuestion | Should Be 42
		     }
    }
}

Continue reading “Use Pester to author your PowerShell scripts”