[CmdletBinding()] param( [string]$MentorHome = $env:SDD_HOME, [string]$DmsRoot = $env:DBEDIR, [string]$DmsLoginConfig ) Set-StrictMode -Version Latest $items = @() function Add-Check([string]$Name, [bool]$Present, [string]$Detail) { $script:items += [pscustomobject]@{ name=$Name; present=$Present; detail=$Detail } } if ([string]::IsNullOrWhiteSpace($MentorHome)) { Add-Check 'SDD_HOME' $false 'Environment variable is empty.' } else { Add-Check 'SDD_HOME' (Test-Path -LiteralPath $MentorHome -PathType Container) $MentorHome } if ([string]::IsNullOrWhiteSpace($DmsRoot)) { Add-Check 'DBEDIR' $false 'Environment variable is empty.' } else { Add-Check 'DBEDIR' (Test-Path -LiteralPath $DmsRoot -PathType Container) $DmsRoot } $jvmCandidates = @() if ($DmsRoot) { $jvmCandidates += (Join-Path $DmsRoot 'jre\bin\client\jvm.dll') } if ($MentorHome) { $jvmCandidates += (Join-Path $MentorHome 'common\win32\jre\default\bin\client\jvm.dll') } $jvm = $jvmCandidates | Where-Object { Test-Path -LiteralPath $_ -PathType Leaf } | Select-Object -First 1 Add-Check 'JVM' ($null -ne $jvm) ($(if ($jvm) { $jvm } else { ($jvmCandidates -join '; ') })) $dmsBat = if ($DmsRoot) { Join-Path $DmsRoot 'bin\dmsdesktop.bat' } else { '' } Add-Check 'DMS desktop launcher' (-not [string]::IsNullOrWhiteSpace($dmsBat) -and (Test-Path -LiteralPath $dmsBat -PathType Leaf)) $dmsBat if ([string]::IsNullOrWhiteSpace($DmsLoginConfig)) { Add-Check 'DMS login config' $false 'Pass -DmsLoginConfig when running the real check.' } else { Add-Check 'DMS login config' (Test-Path -LiteralPath $DmsLoginConfig -PathType Leaf) $DmsLoginConfig } $result = [pscustomobject]@{ ready = (@($items | Where-Object { -not $_.present }).Count -eq 0); checks = @($items) } $result | ConvertTo-Json -Depth 6 if (-not $result.ready) { exit 3 } exit 0