17

I'm looking for something like a Powershell script to check if msdeploy is installed and if it is, what version

I've considered checking "c:\Program Files\IIS" and checking for MSDeploy installations there, but is this always guaranteed to be the install location?

I need this to work on any given server machine

2
  • msdeploy | find "Version"? Feb 26, 2013 at 19:54
  • @JoachimIsaksson this would only work if it is set up in the PATH variables Feb 26, 2013 at 20:17

4 Answers 4

17

When msdeploy is installed (no matter where in the file system), it will add its install path to the registry at;

HKLM\Software\Microsoft\IIS Extensions\MSDeploy\<version>\InstallPath

and its version information to;

HKLM\Software\Microsoft\IIS Extensions\MSDeploy\<version>\Version

...where <version> is currently 1, 2 or 3 depending on the WebDeploy version you have installed.

1
  • 2
    Note that InstallPath and Version are not subkeys, but rather they are values on the <version> key. (Important if you're looking at this programmatically.)
    – jpmc26
    Mar 12, 2015 at 21:03
7

Depends on what you consider "version". By the folder name "c:\Program Files\IIS\Microsoft Web Deploy V3", the version is 3, but if you run msdeploy.exe, the version is 7.X

3

This is what I did in my PowerShell script:

$WebDeployInstalled = Get-WmiObject Win32_Product | ? {$_.Name -like '*Microsoft Web Deploy*'}
if ($WebDeployInstalled -eq $null)
{
    $msg = "Microsoft Web Deploy is not found on this machine."
    Write-host -BackgroundColor Red -ForegroundColor White $msg
    return
}
else
{
    $MSDeployPath = Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\IIS Extensions\MSDeploy\*" | Select-Object InstallPath
    $MSDeployPath = $MSDeployPath.InstallPath
}

HTH

1

You can use the following PowerShell snippet:

$installPath = $env:msdeployinstallpath
if(!$installPath){
    $keysToCheck = @('hklm:\SOFTWARE\Microsoft\IIS Extensions\MSDeploy\3','hklm:\SOFTWARE\Microsoft\IIS Extensions\MSDeploy\2','hklm:\SOFTWARE\Microsoft\IIS Extensions\MSDeploy\1')
    foreach($keyToCheck in $keysToCheck) {
        if(Test-Path $keyToCheck){
            $installPath = (Get-itemproperty $keyToCheck -Name InstallPath -ErrorAction SilentlyContinue | select -ExpandProperty InstallPath -ErrorAction SilentlyContinue)
        }
        if($installPath) {
            break;
        }
    }
}

If you wrap it into script block then you can call it in remote session.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.