Skip to content

Instantly share code, notes, and snippets.

@wgv-zbonham
Last active June 14, 2016 21:09
Show Gist options
  • Save wgv-zbonham/4e843243319949704f4ce431490575da to your computer and use it in GitHub Desktop.
Save wgv-zbonham/4e843243319949704f4ce431490575da to your computer and use it in GitHub Desktop.
Print-WgvDbVersion
param([int]$databaseVersion)
<#
.SYNOPSIS
Converts Database Version [int] to human readable string.
.DESCRIPTION
Converts Database Version [int] to human readable string.
build = value & 0x0fff
rev = (value >> 12) & 0xf
minor = (value >> 16) & 0xff
major = (value >> 24) & 0xff
.PARAMETER $dbVersion
Required. The value of the dbo.Version.Version column.
.EXAMPLE
Print-WgvDbVersion 67175665
4.1.0.1265
#>
function Print-WgvDbVersion([int]$dbVersion) {
$major = ($dbVersion -shr 24) -band 0xff
$minor = ($dbVersion -shr 16) -band 0xff
$rev = ($dbVersion -shr 12) -band 0xf
$build = ($dbVersion -band 0x0fff)
"{0}.{1}.{2}.{3}" -f $major, $minor, $rev, $build
}
Print-WgvDbVersion $databaseVersion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment