2016/05/22

Montreal PowerShell User Group #03 - Future of our user group



Join us for the Montreal PowerShell User Group #03 meeting on the Tuesday 24th of May 2016 from 6:00pm to 8:00pm at the Warner Brothers Games Studio.

Registration: Seats are limited, please RSVP on Meetup.com

This will be a social event, a bit different from the previous ones. We will discuss the future of the user group and gather your feedback.

There is no technical presentation planned but if the time permits it, you are welcome to show off/talk about some of your success stories using PowerShell or bring your scripts if you need help.

We plan to have some Pizza & Pop Corn!

More details on meetup.com

Hope to see you there!

When 

Tuesday, 24th of May 2016 from 6:00pm to 8:00pm

Where

Warner Brothers Games - 888 Maisonneuve Est - 6th Floor
Room: Jack Warner (In front of elevators)

2016/05/11

Using Pester to test your Manifest File

In my previous post I got started with Pester and wrote my first test against the Comment Based Help of my module AdsiPS.

Next, I wanted to write a Pester test against the Manifest File of AdsiPS module. I want to make sure all the basic information of the module is referenced in this file. Mike Robbins wrote a great article on Dynamic Unit Tests where he is touching some of the points I want to cover today.


But before I get into the code, a small reminder on the Manifest file's role.

What is a Manifest File ?


A module manifest is a Windows PowerShell data file (.psd1) that describes the contents of a module and determines how a module is processed. The manifest file itself is a text file that contains a hash table of keys and values. You link a manifest file to a module by naming it the same as the module, and placing it in the root of the module directory.

For simple modules that contain only a single .psm1 or binary assembly, a module manifest is optional. However, it is recommended that you use a module manifest whenever possible, as they are useful to help you organize your code and to maintain versioning information. More info.
(You'll find at the end of this article the command that I use to generate my manifest.)


2016/05/10

Using Pester to test your Comment Based Help

Update 2016/11/25: Updated the code to support functions where there is no parameter declared (Thanks Wojciech Sciesinski !!!)

I remember attending a meeting on Pester presented by Dave Wyatt back in November 2014 during my first MVP Summit.

A couple of well known PowerShellers were there: Boe Prox, Emin Atac, Adam Driscoll, Mike Robbins, Fabien Dibot, Jan Egil Ring, Steve Murawski, ...  It was a great event, great to finally meet all those guys...

Anyway, at the time Pester looked pretty neat but since I only played with it a couple of times and never really invest or commit myself to create tests for each of my scripts or modules.

During the Microsoft MVP Summit 2014 week (Bellevue, WA, USA)
Evening event organized by Dave Wyatt on Pester.

2016/05/08

Create a function/Cmdlet alias using the [Alias()] attribute

Just wanted to share a small PowerShell tips that Kirk Munro found.
You can declare a function or Cmdlet Alias using the following technique:

function Get-This
{
    [CmdletBinding()]
    [Alias("Get-That")]
    PARAM (
        $Param1
    )
    
    Write-Output "Param1 = $param1"
}

Get-That -Param1 "Hello World"


According to Jason Shirk this has been added in PowerShell v4.0:
"Support for the alias attribute on a function or cmdlet (works in C# too!) was added in V4.
It’s most valuable in a binary module because it’s harder to create aliases via IModuleAssemblyInitializer and when you do via that interface"