TestLogetoModuleIntegrity.ps1
function Test-LogetoModuleIntegrity { $hashsums = Get-ChildItem (Join-Path -Path $PSScriptRoot -ChildPath "*.md5") foreach ($hashsum in $hashsums) { $lines = Get-Content -Path $hashsum.FullName foreach ($line in $lines) { $line = $line.Trim() if ($line.Length -ne 0) { if ($line -match "(?<FileHash>[a-zA-Z0-9]+)\s+(?<FilePath>\S.*)") { $fileHash = Get-FileHash -Algorith MD5 -Path (Join-Path -Path $PSScriptRoot -ChildPath $Matches["FilePath"]) if (!($fileHash.Hash -eq $Matches["FileHash"])) { return $false } } else { return $false } } } } return $true } |