18

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"? Commented Feb 26, 2013 at 19:54
  • @JoachimIsaksson this would only work if it is set up in the PATH variables Commented 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.

Sign up to request clarification or add additional context in comments.

1 Comment

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.)
8

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

Comments

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

Comments

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.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.