Skip to main content


Showing posts from 2015

Powershell Gallery – For your pleasure

Sad to say this, however I received an account for Powershell Gallery to be able to submit modules to the new PowershellGet (formerly know as OneGet)  ecosystem a looong time ago. Today was the first time I published a module to the repository. The work involved was, like I expected, very light. Process went smoothly and my module was uploaded within 10 seconds.

If you have not looked into it yet, I highly recommend you start to dig in. The statistics on show that there is a dramatic increase in downloads the last couple of months. I expect this to increate as time goes by and by the fact that there is a package management preview available for people with Powershell version 3.0 or 4.0 running in Windows Server 2008 R2, Windows7, Windows8, Windows Server 2012 and 2012 R2 (download link). Please note that the preview is dependent on .Net version 4.5.

First module

So what did I upload as my first module? Well after being on Windows 10 for a couple of months (yes,…

Use powershell to validate Email address

A time comes along when you need to validate an Email address using Powershell. Created a function just for this purpose as an introduction to how you may create advanced functions in powershell.

This function will “validate” an email address using the System.Net.Mail namespace and output an Boolean value indicating if an string is a valid address. It uses a structure and style that is my personal preference. Feel free to comment if you like.

Basic learning points

It is an advanced functionIt supports the pipelineIt displays how to create an instance of a .Net class



What is around the corner for IT-Pros – Part 2

This is part 2 of a multi post around topics discussed in Part1. Next up is Hybrid Cloud and how it will impact us and why it is the way of the future.

Hybrid cloud

Microsoft changed their focus a couple of years ago, from the primary solution provider for enterprise software running in datacenters to a Mobile/Cloud first strategy. Their bet was that the cloud would be more important and that the economic growth would be created in the emerging cloud market. Needless to say that it looks like their bet is paying of tenfold.


Over the last year there have been a significant number of announcements that connect Azure to your datacenter, thus enabling enterprise to utilize cloud resources with enterprise On-Prem datasources or local hybrid runbook workers. It should not come as any surprise that this trend is accelerating in preparation for the next big shift in hybrid technology, that is expected to be released with Windows Server 2016 – Microsoft Azure Stack. Before we go down that …

Help yourself if you ask for help

This is a slight modification of a Reddit post I created a few months ago. It was written for Reddit, however the analogy works even if you ask for help anywhere else too.

I have not been on Reddit for long, however I have been watching the posts being submitted. In all fairness, I have a couple of suggestions to you if you need help with something larger than a commandline or suggestion of a command line:

How to ask for help

Always state the goal of the solution.What is the problem you have decided to try and solve. If your solution is to produce output, explain what it should output and what form (console, xml, json, text, csv etc).How will the solution be executed (as a script, as part of an module or as an function)If your solution is not working, share the whole script/function included dependency code, not just the line/command/function that is not working.If you code requires parameters and your code does not include any help/comments on how it works, explain what the parameters a…

Powershell – Log like you mean it

How do you do logging in powershell? Why should you do logging? What should you log? Where do you put your log? How do you remove your log? How do you search your log? All important questions and how you answer then depends upon what your background is like and the preferences you have. This will be a 2 part blog post and this is part 1.

Why should you log?

Well it is not mandatory, however I have 2 reasons:
Help with debugging a script/module/functionSelf documenting script/module/function
Firstly; Do you know any program that does not contain any bugs? Working with IT for the last 2 decades, I cannot name one. When you create scripts/modules/functions, you will create bugs, that is where they live and try to make your life a living mess.

Secondly: Adding a little extra information to your logging will make them self documenting. Do you like writing documentation? Well I normally am not fond of it and use logging while debugging to get two birds with one stone.

What should you log?


What is around the corner for IT-Pros – A new dawn?

After spending last week at the IT Dev Connections conference, I thought I should share some insight.

This was the first time I attended the conference, and I must admit it was a nice substitute for Microsoft Ignite which I was not able to attend. Key take away from the sessions and content presented is:

Automation and integration – do more work with less effortHybrid cloud is here to stayAzure is removing dependencies (System Center) ASROnPrem presence is still substantialContainers – Docker and Docker for WindowsIT Dev Connections – A great conference

IT Dev Connections
First off, this was held in a great place (Las Vegas). The venue (Aria) was perfect with nice auditoriums (not to big) and very good internet connection (Aruba rules). By my estimates, there were around 1500 participants (I do not have an exact figure). Compared to Ignite, which is around 20.000, it is more personal than those big conferences. They also managed to mix the agenda with a nice blend of Cloud/Azure/VMWare, O…

Write-Host – Will the puppies survive

Just updated my virtual computer running Win10. Yes, I am a chicken and have not upgraded my computer from 8.1 yet. Some time in the future I will find time to upgrade, however in the mean time I am quite happy with just running it as a VM.

My current build of powershell is 10041 (yes, I know I am falling behind). I was tweeting with Jan Egil (@JanEgilRing). He mentioned a new cmdlet and a couple of new common parameters that has become available in this build.

We have two new common parameters:
Using my previous get all common parameters, we can indeed confirm that these are new common parameters:

There is also a new cmdlet called Write-Information which has 2 parameters:

There is a new $InformationPreference global variable set to “Continue” by default.

In action
So here is the first attempt to write something in the console:

Write-Information produced no information in the console. Turns out it is not a bug, however a f…

Getting things done

Attended one of those sessions where the key selling point was “how to get things done”. In other words, get your sh*t together and get organized with zero emails in you inbox. It is a whole philosophy, google it :-)

Well one of the suggestions was to use the “send to onenote” program that is installed with OneNote. Of course that is way to may clicks for me and my mouse and I started to look into a quicker way of doing it in powershell, what else?

Turns out there are very few posts on the subject, sending things from powershell to OneNote. Found a couple of references using c# and that is almost powershell so of I went and created this function Out-Note.


The function takes two parameters. Note = The text you want to send to OneNote and an optional parameter Section that defaults to “General”.

UPDATE - 23 March 2015

Received a tweet from Jan Egil Ring (Powershell MVP - @JanEgilRing). He was having issues with the function. It would only create a new page in OneNote if OneNote w…

Devops – Unit testing in Powershell Part 2

Powershell has really gained a strong momentum the last 3-4 years and is becoming increasingly the scripting language of choice if you live in the Windows part of the IT world. Together with the increasing popularity of the Devops phrase, unit testing is a key factor going forward.
This is part 2 (Part1) of a small series of posts related to unit testing in Powershell. You can read the first post her.

In the previous post we presented the Scenario we will be working with and the API functions that our SillyModule will wrap logic around.

The tasklist
Read up on Unit Testing frameworks for powershell (Pester or PSUnit)Create the the SillySystem Import-Object and Export-Object APIWalk through of the module and the functions (Get/Update-Person/Group)Create tests for the functionsRefactor where needed ad update the testsThe SillyModule

The context of the module is pretty simple. We need cmdlets to receive a list of persons or groups. The list may be filtered on a specific property (Name or Obj…