[HOWTO] Access Azure File Share in PowerShell Script executed by a Scheduled Task

Last week I had to set up an Azure File Share for data transfer purposes. Clients will upload data to the Azure File Share and the data will then be moved from the share to a local drive by a PowerShell script. The PowerShell script gets invoked every 15 minutes by a Scheduled Task. The […]

[HOWTO] Access Microsoft Access Database with PowerShell

In one of our current projects we had to access a Microsoft Access Database (.mdb) with PowerShell. I first tried to access the .mdb using the Invoke-SqlCmd Cmdlet from our PowerShell module biz.dfch.PS.System.Data. Unfortunately connecting to the Access database with the Invoke-SqlCmd Cmdlet does not work as it uses SqlClient from the C#/.NET namespace System.Data […]

Get NetworkCredential from PSCredential splits Username into Username and Domain

During development of a PowerShell binary module I had to do deal with two different credential types (System.Management.Automation.PSCredential and System.Net.NetworkCredential) and came across a behaviour I wanted to write down. The PowerShell binary module I developed contains several Cmdlets. One of them defines a parameter of type System.Management.Automation.PSCredential. Inside the Cmdlet we need to have […]

[NoBrainer] Start-Sleep takes longer that it seems

While doing some tests with our new TraceListener and log server I did some tests where I wanted to find out how long the log server would take to start accepting messages. So I started to constantly send messages from the console: When I looked at the server logs I noticed that the arriving messages […]

How to Write a PowerShell Binary Module – revisited

Module Configuration Variable

Recently I started writing a PowerShell binary module in C# (mainly due to facilitate testing and move away from Pester limitations). In this post I will describe the format of our PowerShell module and the format of the respective Cmdlets, plus logging and testing integration. My first attempt was to create a module for Abiquo […]

Logging in PowerShell with System.Diagnostics.TraceSource and log4net

Microsoft .NET offers a very flexible logging system exposed via the System.Diagnostics namespace. Unfortunately (and not surprisingly), by default the pre-packaged listeners do not support writing messages to log4net directly. However, we can extend the logging outputs by implementing custom TraceListeners and when asking our favourite search engine for “TraceListener log4net” we find there are […]

[HOWTO] Set up PowerShell Remote Session Configuration

Todays blog post is about setting up a PowerShell remote session configuration on a Windows machine. A PowerShell remote session configuration can be used when connecting from another machine (hereinafter called as Client) to the machine the PoSH remote session configuration resides on (hereinafter called as Target) using Enter-PSSession Cmdlet. A PoSH remote session configuration […]

[HOWTO] Automatically applying PSDefaultValue to C# based PSCmdlet Parameters

One of the cool features of PowerShell script based Cmdlets is the possibility to define default values for Cmdlet parameters. This is typically done like this: Whenever we invoke such a Cmdlet without specifying the Name parameter the PowerShell runtime will insert the value my default value into that parameter. C# based PSCmdlet provide a […]

Unit Testing C# binary PowerShell Modules

For years all our PowerShell modules we released were script modules (i.e. they were written in PowerShell). However, it is certainly possible to write PowerShell modules in C# as binary modules. Of course there are already plenty discussions whether one or the other approach is better. It really depends on the exact requirements. For us […]

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 […]