[CmdletBinding()] param( [Parameter(Mandatory)][string]$LmcFile, [Parameter(Mandatory)][string]$BlockName, [Parameter(Mandatory)][string]$LibSpec, [Parameter(Mandatory)][string]$DmsLoginConfig, [string]$MentorBin = $env:SDD_LM_BIN, [string]$ReportPath, [string]$EvidenceJson, [int]$TimeoutSeconds = 120 ) Set-StrictMode -Version Latest $ErrorActionPreference = 'Stop' $module = Join-Path $PSScriptRoot 'CBBRefresh.Core.psm1' Import-Module $module -Force try { $invokeArgs = @{ LmcFile = $LmcFile BlockName = $BlockName LibSpec = $LibSpec DmsLoginConfig = $DmsLoginConfig MentorBin = $MentorBin ReportPath = $ReportPath TimeoutSeconds = $TimeoutSeconds } $check = Invoke-CbbReuseBlockContentCheck @invokeArgs if (-not [string]::IsNullOrWhiteSpace($EvidenceJson)) { $parent = Split-Path -Parent ([IO.Path]::GetFullPath($EvidenceJson)) if ($parent -and -not (Test-Path -LiteralPath $parent -PathType Container)) { New-Item -ItemType Directory -Path $parent -Force | Out-Null } $check | ConvertTo-Json -Depth 8 | Set-Content -LiteralPath $EvidenceJson -Encoding UTF8 } $check | ConvertTo-Json -Depth 8 switch ($check.result) { 'pass' { exit 0 } 'fail' { exit 4 } 'timeout' { exit 5 } default { exit 3 } } } catch { $errorResult = [pscustomobject]@{ operation = 'reuse_block_content_check' result = 'error' error = $_.Exception.ToString() lmcFile = $LmcFile blockName = $BlockName } $errorResult | ConvertTo-Json -Depth 8 if (-not [string]::IsNullOrWhiteSpace($EvidenceJson)) { $errorResult | ConvertTo-Json -Depth 8 | Set-Content -LiteralPath $EvidenceJson -Encoding UTF8 } exit 2 }