Powershell: Verify if a application is installed (the right way)!

September 14, 2011

There are a few different ways to skin this problem… An initial search will point you in the direction of using WMI Win32_Product class. Avoid this at all costs for reasons mentioned here.

Use this approach instead:

gci "HKLM:\software\Wow6432Node\Microsoft\windows\CurrentVersion\Uninstall" | %{ gp $_.PSPath } | where {$_.DisplayName -match "{Application Name}"}



PowerShell: List all installed hotfixes & list all installed applications

October 8, 2010

Two quick PowerShell one liners.

This PowerShell one line script will output a list of installed hotfixes:

gwmi -Query "Select * from Win32_QuickFixEngineering" -ComputerName <ComputerName>| `
Sort-Object -Property  HotFixID| `
Format-List HotFixID, Description, Caption | `
Out-File c:\<ComputerName>.InstalledHotFixes.txt

This PowerShell one line script will output a difinitive list installed via Windows Installer (MSI):

gwmi win32_product -computername <ComputerName> | `
Sort-Object -Property InstallDate | `
Format-Table Name,Version | `
Out-File c:\<ComputerName>.InstalledProducts.txt


Powershell: A one line script to terminate all BizTalk suspended messages

October 7, 2010

Here is a quick powershell script which terminates all suspended messages on a local BizTalk Server host.

This script includes all service instances, you can however very easily modify the script for finer control to use any other different set of properties for each instance. For example if you included the condition ‘ServiceClass = 4’ as well you would be only terminating “messaging” service instances.

Here is the script.

Get-WmiObject MSBTS_ServiceInstance  -namespace 'root\MicrosoftBizTalkServer' -filter 'ServiceStatus = 4'  |`
%{Get-WmiObject MSBTS_ServiceInstance -namespace 'root\MicrosoftBizTalkServer' -filter "InstanceID = '$($_.InstanceID)'"} |`
%{ $_.Terminate()} |`
%{ Out-Null }


BizTalk deployment using Windows PowerShell Part 1: Applications and Host Instances

September 24, 2010

Windows Powershell is the (not so) new command and scripting language from Microsoft. One of Powershell’s biggest features is the ability to leverage the power of the .NET framework directly from the command line. I am finding myself drawn to using Powershell more and more in many different scenarios, especially when I comes to automating deployment tasks.

BizTalk deployments are commonly made up of many different tasks spanning beyond just building, importing and installing a BizTalk solution. Often there are many pre and post build tasks which are required to complete the job. I have on occasion been involved in deployments which would have been simplified through automation with Powershell scripts.

In this series of posts I plan to post some of the scripts which I have written which can be reused or used as a guide to simplify common deployment tasks.

  1. Script 1 stops all running BizTalk applications (fully) and stops all host instances: BTSStopAllAppsAndHostInstance.ps1
  2. Script 2 starts all running BizTalk applications (fully) and starts all host instances:BTSStartAllAppsAndHostInstance.ps1

So what are contained within these scripts?

These scripts have been written for use against BizTalk Server 2009, and as such retrieve the BizTalk Server 2009 installation path from the windows registry. For control of the BizTalk Server applications, the Microsoft.BizTalk.Explorer.OM assemblies are used, while for the BizTalk host instances the Get-Service Powershell commandlet is used.

For more information I suggest reading up more about what I have done here using the following links: