Skip to content

Category: PowerShell

Microsoft PowerShell

PowerShell 0

Backward Compatible Tags in PowerShell 5 Module Manifest

A few months ago we started to publish our PowerShell modules to PowerShellGallery. PowerShellGallery visualizes the PSData defined in PrivateData of module manifest, which got introduced in PowerShell 5. PrivateData part of a module manifest file created with the New-ModuleManifest Cmdlet of PowerShell 5. Because of that we extended the module manifest files of our existing modules with the PrivateData […]

PowerShell 0

[NoBrainer] Getting constructor information with PowerShell 5 easily

Before PowerShell 5 we had to revert to reflection to be able to display constructor information in PowerShell (see Get-Constructor Fun for details). And because we used that functionality so often we created a Cmdlet Get-Constructor that is part of our biz.dfch.PS.System.Utilities module. However with PowerShell 5 this is obsolete as it is now built into the language and runtime […]

PowerShell 0

[HOWTO] Analyze PowerShell Scripts with PSScriptAnalyzer

A few weeks ago we started publishing our PowerShell modules to PowerShell Gallery. After publishing the module biz.dfch.PS.Appclusive.Client the first time we got an email from PowerShell gallery with some code analysis results with severity Error. As written in the email the analysis was performed with a module called PSScriptAnalyzer. We considered the project description and documentation at GitHub and […]

PowerShell 0

[NoBrainer] Avoiding Concurrency Exceptions when working with a DataServiceContext in PowerShell

When working with a DataServiceContext from PowerShell you might run into concurrency update situations after updating entities via SaveChanges. This is due to the behaviour of the DataServiceContext ChangeTracker which will not reflect changes performed by the server (as a result of our update operation). Let me illustrate this with a quick example: Suppose we have a Catalogue entity where […]

PowerShell 0

Improving Pester and Exception Assertion

Today’s post will cover the Pester testing framework. If you ever have used Pester for more the sunshine scenarios you will have noticed that the assertion of exceptions is a little bit, hmm, awkward. Pester provides an integrated Throw operator that will parse the exception message. This has some limitations such as when running in non-english environments the message may […]

C#/.NET 0

The Case of the mystery log4net logging Behaviour when using PowerShell and C# with multiple Configurations

This blog post is about log4net which switches log configurations within a process as soon as two components are using their own log4net configuration. As you can read from our numerous blogs we are using PowerShell in combination with C# quite extensively. In addition we are heavily relying on log4net for logging puposes (see our PowerShell module biz.dfch.PS.System.Logging (available at […]

C#/.NET 0

[HOWTO] Execute C# build from PowerShell on Jenkins

At d-fens we usually use JetBrains TeamCity as a build server. Because one of our customers uses Jenkins as build server I had the chance to set up a build job for one of our C#/.NET projects on Jenkins. The project I mentioned is a C#/.NET Web Application built with Visual Studio 2013. For testing we make use of the […]

PowerShell 0

[NoBrainer] ‘The Should command may only be used inside a Describe block’ when run in an interactive PowerShell session

Here is a small helper method that you can use when creating Pester tests and trying to run them in an interactive PowerShell session. When executing statements that include the Pester Should Cmdlet interactively in a PowerShell session you receive the following error message: With the Should helper method below you can still execute the original Pester statement without having […]

PowerShell 0

[NoBrainer] Performance Considerations regarding using Guid.ToString vs Guid.Guid in PowerShell

While doing some performance optimisations on one our loader scripts I came across an issue of converting a System.Guid or [[Guid]] in PowerShell to a string representation. In C# I was always (and still am) using ToString() and never saw anything like a Guid property. However, for some reason in PowerShell I tended to use the Guid property (instead of […]

PowerShell 0

Transient Fault Handling with PowerShell

We are using PowerShell to automate various backend systems quite heavily. Sometimes these interfaces (which may be REST APIs, message queues or something completely different) are shortly not available because of intermittent failures or simply because of network issues. In any case, most of the time a script will crash, though quite a bunch of work in this script might […]

PowerShell 0

Assert and Exception Logging made easy in PowerShell

In this post I would like to present you a way of how to easily perform assertions like error checking and result validation with PowerShell based on an idea of the Microsoft Code Contracts library. We at d-fens spend quite some time writing PowerShell scripts that automate and integrate various backend systems where unforeseen events not only happen but are […]

PowerShell 3

[HOWTO] Sign PowerShell Script with SuisseID

We at d-fens all have a SuisseID, which can be used for different purposes like authentication and electronical signing purposes. It’s as well possible to sign code with the SuisseID. The advantages of using the SuisseID for code signing are that the SuisseID is a very cheap in comparison to other code signing certificates and that the user gets authenticated […]