Since my last post on how to deploy a MSU file I received a lot of comments on how I should really be using PowerShell for the detection clause. As there are many ways to skin a cat, and as luck would have it I just so happened to need to deploy another MSU, I have documented my approach on using PowerShell as a detection clause. I’m hoping this will keep the moaners happy for a bit… 😉
One advantage of using PowerShell is that you could deploy multiple msu’s at once and use PowerShell for the detection of all of them. I’ve not had to do this but it could come in handy eh? Nah you’re right, probably not.
Here is the table I used as a reference that I stole from Technet that explained what I needed to do in the PowerShell code in order to signify a successful installation…simply write to the host! (stdout)
Table referenced here: https://technet.microsoft.com/en-gb/library/gg682159.aspx
So with that in mind, here is how I deployed a MSU the other day using Powershell as a detection clause….step-by-step:
And here’s where the magic happens…(You can ‘Write-Host’ anything you like here, I used “Installed!” but as long as you write something to the stdout stream it will signify a successful detection.)
I’m not going to explain the PowerShell as it’s pretty obvious what’s going on…and yes…I know I can shorten all of this to one line but it’s more flexible and readable this way, so there!