How to find out what version of webdeploy/msdeploy is currently installed?

时光总嘲笑我的痴心妄想 提交于 2020-03-21 11:04:27

问题


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


回答1:


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.




回答2:


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




回答4:


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.



来源:https://stackoverflow.com/questions/15098030/how-to-find-out-what-version-of-webdeploy-msdeploy-is-currently-installed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!