Get installed version number from multiple Umbraco websites automatically
Hi all.
is it possible to get installed version number from multiple Umbraco websites automatically ? we have a list of our customers websites and it would be awesome if the list could update the umbraco version automatically via a query parameter or something similar.
If you have the sites on the same server and have full access to it (like RDP access), you can run a Powershell script to traverse the IIS directories and list the version number of one of the Umbraco dlls.
We did this when we needed to check which sites had to be patched when an Umbraco security patch was released.
If you don't have access to run a Powershell script, you would have to find another way. There was a talk at CodeGarden a few years ago where someone presented a review/list of sites and what version of Umbraco they were running (and also which plugins they had installed), but it depended on checking for the existence of particular files that were specific to different versions of Umbraco (and their plugins). Unless you have hundreds of sites (or someone else chips in) it would probably take longer to find out the mechanics of this that it would take to do it manually.
Here's a script that works (for us) to emit the versions supporting both .net framework versions (4, 6, 7, 8) by reading the web.config appsetting Umbraco.Core.ConfigurationStatus or umbracoConfigurationStatus and .net core/modern versions (10+) by reading the Umbraco.core.dll product version attribute.
It was written by chatGPT with some trial and error revisions (10!) but I've tested it on our server where we have a path structure like so: \webroot\clientname\sitename.fqdn.com\htdocs\<umbracosite>
If your hosted path structure is different to ours, then you may need to alter the script a bit.
# Set the root directory
$rootDirectory = "D:\WebRoot"
# Initialize a list to store the paths of identified Umbraco sites
$umbracoSites = New-Object System.Collections.ArrayList
# Step 1: Traverse to find Client and Site folders, then check for umbraco.core.dll in the appropriate locations
function DiscoverUmbracoSites {
param (
[string]$rootDirectory
)
# Find all Client folders within the root directory
$clientFolders = Get-ChildItem -Path $rootDirectory -Directory
foreach ($clientFolder in $clientFolders) {
# Find all Site folders within each Client folder
$siteFolders = Get-ChildItem -Path $clientFolder.FullName -Directory
foreach ($siteFolder in $siteFolders) {
# Check for umbraco.core.dll in htdocs or htdocs\bin
$htdocsPath = Join-Path -Path $siteFolder.FullName -ChildPath "htdocs"
$binPath = Join-Path -Path $htdocsPath -ChildPath "bin"
# Check if umbraco.core.dll exists in htdocs folder
$dllInHtdocs = Get-ChildItem -Path $htdocsPath -File -Filter "umbraco.core.dll" -ErrorAction SilentlyContinue | Select-Object -First 1
if ($dllInHtdocs) {
# Add the path to the list with indication to use DLL version identification
$null = $umbracoSites.Add([PSCustomObject]@{
ClientFolder = $clientFolder.Name
SiteFolder = $siteFolder.Name
DllPath = $dllInHtdocs.FullName
VersionSource = "dll"
})
Write-Output "Found $($umbracoSites.Count) Umbraco sites"
continue
}
# Check if umbraco.core.dll exists in htdocs\bin folder
$dllInBin = Get-ChildItem -Path $binPath -File -Filter "umbraco.core.dll" -ErrorAction SilentlyContinue | Select-Object -First 1
if ($dllInBin) {
# Add the path to the list with indication to use appsettings version identification
$null = $umbracoSites.Add([PSCustomObject]@{
ClientFolder = $clientFolder.Name
SiteFolder = $siteFolder.Name
DllPath = $dllInBin.FullName
VersionSource = "appsettings"
})
Write-Output "Found $($umbracoSites.Count) Umbraco sites"
}
}
}
}
# Step 2: Iterate over the discovered sites and perform version identification based on the specified method
function Get-UmbracoVersionFromSites {
param (
[array]$umbracoSites
)
# Initialize hashtable to store unique results by site
$siteResults = @{}
foreach ($site in $umbracoSites) {
# Parse site details from the discovery phase
$clientName = $site.ClientFolder
$siteName = $site.SiteFolder
$dllPath = $site.DllPath
$versionSource = $site.VersionSource
# Determine the folder path (bin or htdocs) where umbraco.core.dll is located
$sitePath = (Split-Path -Path $dllPath -Parent)
$umbracoVersion = $null
if ($versionSource -eq "dll") {
# Use DLL identification method
$fileVersionInfo = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($dllPath)
$umbracoVersion = $fileVersionInfo.ProductVersion.Split("+")[0] # Truncate at the '+' symbol
}
elseif ($versionSource -eq "appsettings") {
# Use appsettings identification method, web.config is located one level up from the bin folder
$webConfigPath = Join-Path -Path (Split-Path -Path $sitePath -Parent) -ChildPath "web.config"
if (Test-Path $webConfigPath) {
$webConfig = [xml](Get-Content -Path $webConfigPath)
# Try to find Umbraco.Core.ConfigurationStatus or umbracoConfigurationStatus in appSettings
$configStatusSetting = $webConfig.configuration.appSettings.add | Where-Object {
$_.key -eq "Umbraco.Core.ConfigurationStatus" -or $_.key -eq "umbracoConfigurationStatus"
}
if ($configStatusSetting) {
$umbracoVersion = $configStatusSetting.value
}
}
# If web.config setting is not available, fall back to DLL version
if (-not $umbracoVersion) {
$fileVersionInfo = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($dllPath)
$umbracoVersion = $fileVersionInfo.ProductVersion.Split("+")[0] # Truncate at the '+' symbol
}
}
# Store the results uniquely for each site based on ClientName and SiteName
$siteKey = "$clientName-$siteName"
if (-not $siteResults.ContainsKey($siteKey)) {
$siteResults[$siteKey] = [PSCustomObject]@{
ClientName = $clientName
SiteName = $siteName
Domain = $sitePath
UmbracoVersion = $umbracoVersion
}
}
}
# Output the results, sorted by ClientName and SiteName
$siteResults.Values | Sort-Object ClientName, SiteName | Format-Table -AutoSize
}
# Run the site discovery process
DiscoverUmbracoSites -rootDirectory $rootDirectory
# Run the version identification and reporting on discovered sites
Get-UmbracoVersionFromSites -umbracoSites $umbracoSites
Get installed version number from multiple Umbraco websites automatically
Hi all.
is it possible to get installed version number from multiple Umbraco websites automatically ? we have a list of our customers websites and it would be awesome if the list could update the umbraco version automatically via a query parameter or something similar.
/best regards Christoffer
This may not be applicable, but in case it is...
If you have the sites on the same server and have full access to it (like RDP access), you can run a Powershell script to traverse the IIS directories and list the version number of one of the Umbraco dlls.
We did this when we needed to check which sites had to be patched when an Umbraco security patch was released.
Unfortunately I don't have the script any more, but something like this might help. https://devblogs.microsoft.com/scripting/how-can-i-get-a-list-of-all-the-dll-files-in-a-folder-along-with-their-version-numbers/
If you don't have access to run a Powershell script, you would have to find another way. There was a talk at CodeGarden a few years ago where someone presented a review/list of sites and what version of Umbraco they were running (and also which plugins they had installed), but it depended on checking for the existence of particular files that were specific to different versions of Umbraco (and their plugins). Unless you have hundreds of sites (or someone else chips in) it would probably take longer to find out the mechanics of this that it would take to do it manually.
HTH
t
Here's a script that works (for us) to emit the versions supporting both .net framework versions (4, 6, 7, 8) by reading the web.config appsetting Umbraco.Core.ConfigurationStatus or umbracoConfigurationStatus and .net core/modern versions (10+) by reading the Umbraco.core.dll product version attribute.
It was written by chatGPT with some trial and error revisions (10!) but I've tested it on our server where we have a path structure like so:
\webroot\clientname\sitename.fqdn.com\htdocs\<umbracosite>
If your hosted path structure is different to ours, then you may need to alter the script a bit.
is working on a reply...