Skip to main content

Posts

Serialize data with PowerShell

Currently I am working on a big new module. In this module, I need to persist data to disk and reprocess them at some point even if the module/PowerShell session was closed. I needed to serialize objects and save them to disk. It needed to be very efficient to be able to support a high volume of objects. Hence I decided to turn this serializer into a module called HashData.



Other Serializing methods

In PowerShell we have several possibilities to serialize objects. There are two cmdlets you can use which are built in:
Export-CliXmlConvertTo-JSON
Both are excellent options if you do not care about the size of the file. In my case I needed something lean and mean in terms of the size on disk for the serialized object. Lets do some tests to compare the different types:


(Hashdata.Object.ps1)

You might be curious why I do not use the Export-CliXML cmdlet and just use the [System.Management.Automation.PSSerializer]::Serialize static method. The static method will generate the same xml, however we …
Recent posts

Create notification in Windows 10

From time to time I find myself needing a notification tool. Normally a simple show messagebox will suffice, however the trouble with that is that is blocking until someone clicks that OK button. I have seen workarounds that uses wscript and other things, however that is just meh.

There is a function in my general purpose repro on BitBucket that is called Show-Message. Here is the function:



The “good” thing about this is that it also works on Windows Server 2016 with the GUI experience, however who is using a GUI on a server nowadays? Everybody should be using Nano or Server Core, right?

In addition the function will fallback to a regular good old MessageBox if the Windows.UI.Notification namespace is not available. Please note that in those scenarios, the function will block execution until the OK button is clicked.

Here is how a notification looks like:



You can also control for how long the notification should be shown to the user with the DisplayDuration parameter.

If you simply want to …

Something completely different – PoshARM

I needed a project for my Xmas holiday and I needed something remotely work related. Thus the dubious PoshARM PowerShell module was born and brought to life during my Xmas holiday. Simply put it is a module that lets you build – for now – simple Azure Resource Manager (ARM) templates with PowerShell . 

The module can also import templates from a file or from the clipboard/string. Your partial template or ready made template can be exported as a PowerShell script. This blog post will walk you through how to use it and the features that is currently implemented. 



Update 08.02.2017:

The module is now published to the PowerShellGallery (https://www.powershellgallery.com/packages/posharm). It is still in beta version, however test coverage have increased and some bugs have been squashed during the testing. Also help is present, however somewhat lacking here and there.

Update 18.01.2017:

The module is now on GitHub. Here is the link to the repro (PoshARM on GitHub)



What is a ARM template?It is a …

Giving a helping hand - Community power

PowerShell is getting increasing attention and gaining followers each day. That is a good thing in my book. I saw a tweet about Citrix OctoBlu automation where Dave Brett (@dbretty) was using it to save money with a PowerShell script (full post here) to power on and off VMs. I reached out to him and asked if he would like a little help with his PowerShell script. To my delight, he happily accepted and this post is about how I transformed his scripts to take advantage of the full power of The Shell. Fair warning is in order, since I have never used or touched a OctoBlu solution.


Starting scripts


(shutdownScript.ps1)



(StartupScript.ps1)



What we would like to change

First of, a PowerShell function should do one thing and do it well. My first goal was to split the function into two parts where we have one function that handles both the startup and the shutdown of the VM-guests. Secondly I would like to move the mail notification out of the function and either put it in a separate func…

Ignite 2016 summary – Innovate, optimize, manage and empower your business with IT

This years Microsoft Ignite conference was all about transforming your business with technology. Here is a techy summary for business-minds.


Going forward, IT-Pros must prepare to answer both tricky business questions, and leverage new tools to meet business demands. I imagine questions like these:

What are the needs of our business? How can we empower our users to apply the cloud to gain competitive advantages? How can we innovate with greater agility and optimize our IT resources? How can we migrate from the traditional model where IT is just a cost-center, to a lean/mean machine where IT is the engine that powers our business strategy with increased earnings?

A model of the traditional business case

We live in a traditional world with traditional problems. Simplified a business consists of a few silos:
Internal users Your customersYour suppliers and partnersThe remainder of the universe
All of these are connected directly and indirectly through processes, some of them manual and some ma…

Windows Server 2016 – DevOps tools and features

I needed to dedicate a full blog post about Windows Server 2016 and the way it will impact you going forward. At some point some of these features will apply to you too, as your infrastructure start to run the new server bits. Here are the highlights from MSignite.

> Highlights
Installation Development Packaging and deployment Configuration Containers Operation Validation and Pester Testing Operating security
> Installation
Server 2016 comes in three flavors. You have the “Desktop experience” server intended for management of other flavors of 2016 or as a terminal server. Next is Server Core which is just the same full server without the desktop and is headless, intended to be managed from Powershell or from a server using the desktop experience. Then there is the new kid on the block, Nano Server. It is the new Cloud OS, born in the cloud and the workhorse for everyone serious about creating modern, lean, super-fast and easy to manage applications. 

Installation of the Desktop Expe…

Microsoft Ignite 2016 – Announcements and features

I have now spent 3 days at Ignite and walked a total distance of about 22km hustling from sessions and the Expo area according to my Iphone. These are some of my thoughts about what might affect you going forward the next year.

HighlightsWindows server 2016 Azure MonitoringAzure FunctionsAzure Networking
Oh yeah, and System Center 2016 was launched. Why is it not on my list? Well to be perfectly honest, the feature list is almost identical to the latest rollup on 2012 R2. More on that later.
Windows Server 2016 GAThis release of Windows server is the chosen one that is going to power the Azure infrastructure and tenant workloads on Azure and AzureStack when it is released next year. From the Hyper-V perspective, things have changed quite a lot. You will have to forget all best practices and how you setup Hyper-V and Storage. 2016 is all about scaleout filesystem (reFS/NTFS) and storage direct.

You also want to check the OEM hardware list to make sure your servers are listed there. Pay e…