Getting the msdeploy.exe install path using powershell

by Naeem Khedarun 17. October 2011 08:00

 

I’ve been playing around with msdeploy and powershell lately, and one of the things I needed to find out is where the msdeploy.exe was located. After building a web deploy package, the associated batch file created by msdeploy uses a registry key to get the executables location.

Accessing the registry in powershell is super easy, so we may as well do the same thing. The key in question is: "HKLM:\SOFTWARE\Microsoft\IIS Extensions\MSDeploy" which we can access using a standard Get-ChildItem or gci for short.

image

I have both MSDeploy v1 and v2 installed, and it’s the latter one I want to get at so we can use a Select –Last 1 to choose it. We also want just the InstallPath property which is accessible via GetValue on the RegistryKey object.

image

Great! We can easily put this into a function and load it into our path using:

function Get-MSWebDeployInstallPath(){
     return (get-childitem "HKLM:\SOFTWARE\Microsoft\IIS Extensions\MSDeploy" | Select -last 1).GetValue("InstallPath")
}

function Load-Configuration
{
    $webDeploy = Get-MSWebDeployInstallPath
    $env:Path += (";" + $webDeploy)
}

You should be able to access msdeploy from your powershell script now…

Categories: PowerShell | msdeploy

Comments

Olinda Geiser
Olinda Geiser United States on 10/31/2011 1:37:17 AM

We are using Umbraco as our CMS offering. Mainly because it fits the type of client we are aiming at a certain price point. Also because it is the best .NET open source CMS that we found.

They are smaller and don't require so many features or fine grain control on security etc.

But of course there are other clients who are prepared to pay for off the shelf features and the license fee that comes with Sitecore or Episerver.

Right now Umbraco is helping us on our way. But as soon as that client comes along who needs that bit more and is prepared to pay the license fee for it, then that's fine with us.

Comments are closed