Monthly Archives: December 2015

PowerShell 5.0 RTM available for download

PowerShell 5.0, part of the Windows Management Framework 5.0 (WMF 5.0), is now released and available in the Microsoft Download Center.


WMF 5.0 is currently available as a separate download for the following Windows versions:

Operating System Service Pack Prerequisites
Windows Server 2012 R2 .NET Framework 4.5 or above
Windows Server 2012 .NET Framework 4.5 or above
Windows Server 2008 R2 SP1 WMF 4.0 is installed and .NET Framework 4.5 or above
Windows 8.1
Windows 7 SP1 WMF 4.0 is installed and .NET Framework 4.5 or above

Currently WMF 5.0 RTM can be installed on older Windows clients, Windows 7 and Windows 8.1,  the updates can be downloaded. On Windows 10 WMF 5.0 is not available as an additional download as Windows Update can be used to update the Windows Management Framework.

Before installing WMF 5.0 on your system, please make sure that you read the released notes as there are currently known incompatibilities with the following products:

  • Microsoft Exchange Server 2013
  • Microsoft Exchange Server 2010 SP3
  • Microsoft SharePoint Server 2013
  • Microsoft SharePoint Server 2010
  • System Center 2012 Virtual Machine Manager

For more information please refer to the Windows Management Framework (WMF) 5.0 RTM Release Notes Overview on MSDN.

For more information on WMF 5.0 and the links in this article please refer to the links below:

Links in this Article
Windows Management Framework 5.0 Download
Windows Management Framework (WMF) 5.0 RTM Release Notes Overview
Known Incompatibilities
PowerShell Team – Windows Management Framework (WMF) 5.0 RTM is now available
Windows Management Framework (WMF) 5.0 currently removed from Download Center

PowerShell Conference EU – Sessions have been approved

Earlier this week I received an email with a joyful message from the organization of of the PowerShell Conference EU. All three of my sessions that I submitted for the conference have been accepted so I am happy to announce that I will be speaking at the PowerShell Conference EU.


The full schedule and all the presentations has not been announced yet, but it promises to be the event that cannot be missed in 2016. The location looks amazing from the pictures and from what I have heard it appears to be a great location. The combination of the speakers, the location and our shared passion for technology will make this into the event that cannot be missed in 2016.


On the official website, the event is listed as follows:
“Welcome to the next great European PowerShell event!

Deutsche PowerShell Konferenz and enthusiastic PowerShell Community Members from all across Europe have united together under the #PSConfEU banner to create an extraordinary PowerShell Community Event in Europe this coming April.

For this conference we will be bringing together PowerShell experts from all around the globe to create a unique 3-day event with presentations, workshops and the chance to connect, learn and discuss all things PowerShell with those that have a real passion for this evolving technology. There will be no place like this to deep-dive PowerShell in all of its flavors and colors.

The conference languages are English and German. There are continuous main tracks in both languages, making sure you can follow the tracks in the language you feel most comfortable with.”

For more information on this event, feel free to follow the official account on Twitter and the Hashtag to stay on top of the announcements.

Links in this Article
PowerShell Conference EU
Twitter – @PSConfEU
Twitter – #PSConfEU



MSFest Prague 2015 – Slides and Code


At the end of November I had the pleasure to attend and speak at MSFest in Prague. This event aimed at the Czech IT Professional and Developer community had a wide variety of topics and I was asked to do two sessions on PowerShell. I presented the following two sessions:

  • PowerShell Security features and threat management
  • PowerShell Advanced Toolmaking

PowerShell Advanced Toolmaking

I have put the presentation and the code online in my Events GitHub repository.

All links in this article are available here:

Links in this Article
MS Fest Praha
Jaap Brasser – GitHub
MSFest Prague 2015 – Code and Slides

PSBlogweek: PowerShell logging in the Windows Event log

This post is part of the #PSBlogWeek PowerShell blogging series. #PSBlogWeek is a regular event where anyone interested in writing great content about PowerShell is welcome to volunteer for. The purpose is to pool our collective PowerShell knowledge together over a 5-day period and write about a topic that anyone using PowerShell may benefit from. #PSBlogWeek is a Twitter hashtag so feel free to stay up to date on the topic on Twitter at the #PSBlogWeek hashtag. For more information on #PSBlogWeek or if you’d like to volunteer for future sessions, contact Adam Bertram (@adbertram) on Twitter.

Once you’re done getting schooled on everything this post has to offer head on over to the announcement for links to the other four past and upcoming #PSBlogWeek articles this week!

An important part of PowerShell scripting is error handling, one of the main differences between a script and a one-liner for me personally is error handling and dealing with exceptions that might occur. For more information on error handling please refer to the previous PSBlogWeek articles where Boe Prox dives into use Try-Catch in order to catch specific errors.

When moving your scripts from into a production environment logging becomes more important, initially using plain text files for logging might be an appropriate solution. Another option however is writing logging information to the Windows Event Log. This has the benefit of being the centralized location where most logging takes place.

Writing to the event log is relatively simple, the Write-EventLog cmdlet can be used for this purpose:


By taking a look at the error message we see that the PowerShell event source is not registered with the application log, in order to resolve this, we can write to the Windows PowerShell event log instead:

Write-EventLog -LogName 'Windows PowerShell' -Source PowerShell -EventId 12345 -EntryType Information -Message 'Script started'


Notice how the command now successfully executes without the error message, this is because it is important for the script

Alternatively, it is also possible to specify a custom event provider, and register this to the correct event log as such:

New-EventLog -Source AwesomeScript -LogName 'Windows PowerShell'
Write-EventLog -LogName 'Windows PowerShell' -Source AwesomeScript -EventId 12345 -EntryType Information -Message 'Script started'


It is also possible to create an entire separate event log for your script logging, also by using the New-EventLog cmdlet:

New-EventLog -LogName 'Scripts' -Source 'Your Script'
Write-EventLog -LogName 'Scripts' -Source 'Your Script' -EventId 12345 -EntryType Information -Message 'Script started'
New-EventLog -LogName 'Scripts' -Source 'Your Script2'
Write-EventLog -LogName 'Scripts' -Source 'Your Script2' -EventId 12345 -EntryType Information -Message 'Script started'


To build upon this, it would be possible to create a script that logs when the script starts, executes an action, when an error occurs and when the script ends.

begin {
    $EventHashInformation = @{
        LogName   = 'Scripts'
        Source    = 'Your Script'
        EventId   = 30000
        EntryType = 'Information'
    $EventHashWarning     = @{
        LogName   = 'Scripts'
        Source    = 'Your Script'
        EventId   = 40000
        EntryType = 'Warning'   
    Write-EventLog @EventHashInformation -Message 'Script started'
process {
    try {
        Get-CimInstance -ClassName Win32_Bios -ErrorAction Stop
        Write-EventLog @EventHashInformation -Message 'Successfully queried Win32_Bios'
    } catch {
        Write-EventLog @EventHashWarning -Message 'Error occurred while  queried Win32_Bios'
end {
    Write-EventLog @EventHashInformation -Message 'Script finished'


Using this method of logging allows for a dynamic form of logging where information such as the timestamp are automatically added to the information. A nice feature of using the event log is that it also allows for exporting the information directory to xml, for example:

Get-WinEvent -FilterHashtable @{
    LogName = 'Scripts'
} | ForEach-Object {$_.ToXml()}


Because this type of logging can quickly fill up the event logs it is important to set the limits and the type of logging the event logs can do. In order to verify the current configuration, we can use the Get-EventLog cmdlet:

Get-EventLog -List | Where-Object {$_.LogDisplayName -eq 'Scripts'} |
Select-Object -Property Log,MaximumKilobytes,MinimumRetentionDays,OverFlowAction


From this we gather that the Minimum retention of this log should be seven days and that only events older than 7 days will be discarded. If the event log is at the maximum size and there are no events older than 7 days to be discarded the latest event will be discarded and will not be written to the script. For more information on this subject please refer to the following MSDN article:

Member name                                                                                                             Description 
DoNotOverwrite Indicates that existing entries are retained when the event log is full and new entries are discarded.
OverwriteAsNeeded Indicates that each new entry overwrites the oldest entry when the event log is full.
OverwriteOlder Indicates that new events overwrite events older than specified by the MinimumRetentionDays property value when the event log is full. New events are discarded if the event log is full and there are no events older than specified by the MinimumRetentionDays property value.

Based on the information in the article, we decide to increase the maximum size of log to 20 MB and to allow overwriting as needed, this is also referred to as circular logging:

Limit-EventLog -Maximumsize 20MB -Logname Scripts -OverflowAction OverwriteAsNeeded
Get-EventLog -List | Where-Object {$_.LogDisplayName -eq 'Scripts'} |
Select-Object -Property Log,MaximumKilobytes,MinimumRetentionDays,OverFlowAction


With the information provided in this article you will be able to:

  • How to write information to the event log
  • How to register an event source to an event log
  • How to create a new event log
  • How to configure an existing event log

I hope this was informative and do not forget to read through the other #PSBlogWeek posts:

Links in this Article
Twitter #PSBlogWeek
#PSBlogWeek Announcement on
MSDN Article: OverflowAction
Adam Bertram Blog
June Blender Sapien Blog
Jason Wasser Blog
Thom Schumacher Blog
Adam Platt Blog
Matt Johnson Blog