Install msi silently with PowerShell

If you have prerequisites for your application, you know how big pain is to install all of them. And after you have done multiple installations over and over again, you can feel as a monkey doing the same thing every time.

To avoid such situations and improve deployment process you probably already started using PowerShell, because it is very very flexible power tool for software deployment challenges.

Recently I added some automatization for deployment process with installing msi in sequence and even without user interaction. Not everything can be installed without user interaction (silently). But you can always choose what to install with UI for user’s input, silent installation without UI and optionally to wait for a msi installation to finish.

In the example below msi setup is installed and PS waits till it is finished. No user interface is displayed, because msi doesn’t require any user input. You can even pass some parameters to MSI.

You can refactor this example to your to needs. And don’t forget to share your script in comments below!

Pass arguments to WIX\MSI setup

It is possible to pass needed arguments to MSI\WIX setups from command line. This approach can be used to make deployments more customizable.

First you need to define properties in WIX definition:

Second, you need to start MSI with parameters to set before defined properties:

In the end, you could get user interface fields pre-filled with your passed values:

WIX MSI example

SVG images display in XAML

Last weekend I was looking for possibility to display SVG images in WPF applications. Svg is an vector image format (two dimensional). It means, that you can scale image without any quality loss and image will stay sharp.

One simple way to do that is to convert SVG image to Canvas object. Or you can create custom Canvas by yourself.

Let say I have SVG image source:

XAML code got from SVG to XAML converter:

What you will see in items control (alternating rows enabled):

SVG example in xamlIt was not so difficult in the end.

Import certificate to store and grant rights with PowerShell

I will show you example how to import certificate to certificates store on computer. In my example I will use pfx certificate, but it doesn’t matter, you can also use *.cer. We will use .NET X509Certificate2 and X509Store classes do do all the work.

At first certificate object is created:

PersistKeySet is set to store certificate’s private key permanently.

Afterwards we get a certificate store and import the certificate to it:

With the same approach we can import to multiple certificate stores the same certificate.

Usually to use the certificate in .NET code you need to grant security rights for account on which app is running, so account could access the certificate’s private key. It can be local account, system account or domain account, but the way to do that is the same.

You need to install WinHttpCertCfg (certificate configuration tool) on machine where your certificate exists and app is running. Default installation path on 64 bit windows is “C:\Program Files (x86)\Windows Resource Kits\Tools”.

After tool is installed needs to run command similar to

winhttpcertcfg.exe -g -c LOCAL_MACHINE\MY -s Test -a “NETWORK SERVICE”

To execute such command in PS you need prefix it with &

If granting succeeds you will get such message:

Matching certificate:

Granting private key access for account:

So whole import PS script will be

If you see any mistake or improvement point, please write it below in the comment. Thanks.

Goodbye Google Reader

Google reader is was my every day tool. Just to show how great it was in good hands, here are some statistics from my usage:

From your 141 subscriptions, over the last 30 days you read 1,295 items, clicked 362 items, starred 0 items, and emailed 0 items.

So I have read almost 100 000 items in last 6 years! I couldn’t believe it myself. RSS reader really saved me hours of clicking via different websites.

Total current subscriptions count maybe is not impressive, but I am constantly removing dead or no more relevant rss feeds.

I already moved all my subscriptions from Google Reader to Feedly. I expect that Feedly will outrun Google Reader functionality soon. I have already found two pros comparing to old reader.

To say the truth, after two weeks with Feedly I am not missing Google reader at all…

Edit config file with PowerShell

Recently I needed to edit machine.config with PowerShell. I thought at first to use config transformations, like I do for application configs (app.config or web.config). But because machine config can have different content (have or don’t have some sections configured) transforming such file becomes complex. I quickly found another solutions for this: xml file editing. PowerShell is very good at it.

Let’s say I have long running transactions on machine. To increase transactions timeout to 1 hour, needs to add or update following configuration in machine.config:

Depending on application platform (32 or 64 bits) and which .NET framework version is used needs to determine which machine config needs to be modified. You also can use .NET RuntimeEnvironment.SystemConfigurationFile property to get machine config location.

Now lets write a function which updates the config file

So that’s all. Here is the working script file. Machine config transformation

Build error after migrating to TFS 2012 from TFS 2010

After migrating to TFS 2012 I came across one annoying issue: builds failing (randomly, as seen at first). The build error is not so informative, but it looks like possible migration issue:

“Specified argument was out of the range of valid values. Parameter name: column.”

TFS 2012 specified argument was out of the range of valid values parameter name columnIf looking at the build log you could get an indirect hint what is going wrong:

Associate Changesets and Work Items
Analyzing labels Client_2013.05.26.3 and Client_2013.05.26.4.

The hint: if checked-in code is associated with work item – build will fail.

But I didn’t notice the hint at first and tried several unsuccessful fixes. After failing I looked at the internet and found the description of the same issue: Upgrading your build definitions from TFS2010 to TFS2012

The suggested quick fix in the article is:

The only workaround in the mean time is to turn off the UpdateWorkItems flag on the AssociateChangesetsAndWorkItems activity. This will cause workitems not to be associated with the build.

So to do that, you don’t necessary need to modify your build template, which maybe would fix with multiple builds using the same process template. Rather you can go to individual build definition – process tab and set “Associate Changesets and Work Items” to false as shown below:

TFS 2012 build definition processSo far, after two days builds are doing fine. Hopefully this quick fix will help you while waiting for the real fix from TFS team.

Updated 2013-05-30

Bug will be fixed in Team Foundation Server 2012.3 (Update 3). More details about the bug:

In an environment that uses TFS 2012 and TFS Build Controller 2010, you check in a TFS 2010 build process template. When you queue a build that has associated work item and the work item has an associated changeset, the build fails with the following error message:

Specified argument was out of the range of valid values. Parameter name: column


ManageWP dashboardFor the last month and a little bit I am using MaganeWP service. It is very useful administration service if you need to manage several WordPress blogs. Till now I am using free version which supports up to 5 WordPress sites.

What I find useful in ManageWP:

1) It is very easy to setup and integrate to your blogs.

2) All sites in one dashboard.

3) Important notifications emailed about your sites (including waiting updates). So you event don’t need to check them every day.

4) One click upgrades for plugins,themes and maintenance\optimization tasks for all sites at once.

These 4 things I find the most useful in the free version. Of course, there is a huge bunch of extra features in paid versions, which maybe I will try in near future.

So, if you haven’t looked yet at ManageWP, I highly recommend to give it a try.