Created
August 27, 2019 14:48
-
-
Save pnmcosta/fea74016525178c7c4e7503d223b78d7 to your computer and use it in GitHub Desktop.
PS script to compute a new file hash for a modified BACPAC
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param ( | |
[string]$fileName = "model.xml" | |
) | |
If (Test-Path $fileName) { | |
$modelXmlPath = Resolve-Path $fileName | |
} else { | |
Write-Host ("File " + (Resolve-Path .) + "\" + $fileName + " does not exist"); | |
exit; | |
} | |
Write-Host ("Creating hash for file: " + $modelXmlPath) | |
$hasher = [System.Security.Cryptography.HashAlgorithm]::Create("System.Security.Cryptography.SHA256CryptoServiceProvider") | |
$fileStream = new-object System.IO.FileStream ` -ArgumentList @($modelXmlPath, [System.IO.FileMode]::Open) | |
$hash = $hasher.ComputeHash($fileStream) | |
$hashString = "" | |
Foreach ($b in $hash) { $hashString += $b.ToString("X2") } | |
$fileStream.Close() | |
Write-Host ("Hash is: " + $hashString) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Original script from: https://techcommunity.microsoft.com/t5/Azure-Database-Support-Blog/Editing-a-bacpac-file/ba-p/368931 modified to accept a
-fileName
parameter and resolve it properly, even from the uncompressed BACPAC package directory.