Adds the PC-DMIS settings/probe backup-restore set alongside the existing goCMM scripts, plus a single combined CMM backup and the diagnostics built while debugging the live bays: - Backup-PCDMISSettings / Install-PCDMISSettings: capture+restore PC-DMIS registry + data/probe/cal files per installed version (2016/2019/2026). Hardened from real-bay failures: detect install dir via Program Files fallback; capture compens.dat (not just comp.dat) + interfac.dll; identify the controller by hash-matching interfac.dll to its source DLL AND reading the PE OriginalFilename (covers rename-without-copy); EXCLUDE the whole Homepage state (Recent/Favorites/DetailsView) which null-refs PC-DMIS on launch via stale routine paths; restore routes HKCU into the target user's hive (-TargetUser ShopFloor), fails loud on a non-backup path, and applies the legacy->new FQDN rewrite across reg + data files incl .bas. - Backup-CMM: one wrapper running goCMM + PC-DMIS (all versions) into one per-CMM folder + index, for staging on PXE and restore-by-machine-number. - Clear-PCDMISRecent: fixes the Homepage recent-list NullReferenceException crash on an already-broken bay. - pcdmis-probe-debug / Export-PCDMISCrashEvents: diagnostics for the custom-probe-not-showing and crash investigations. - Modify-PCDMISRights / Grant-FullControl: grant the operator the registry + filesystem access PC-DMIS needs under lockdown. - Install-goCMMSettings: add .bas to the FQDN-rewrite include list. Not yet wired into 09-Setup-CMM auto-restore - staging + the gated restore block come next. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
63 lines
2.6 KiB
PowerShell
63 lines
2.6 KiB
PowerShell
<#
|
|
Backup-CMM.ps1
|
|
|
|
ONE backup for a whole CMM bay - runs both:
|
|
- Backup-goCMMSettings.ps1 (HKLM goCMM key + C:\geaofi, minus LocalProgramCopies/logs)
|
|
- Backup-PCDMISSettings.ps1 (PC-DMIS registry + data/probe/cal + interfac.dll,
|
|
every installed version; Homepage state excluded)
|
|
|
|
All zips land together in one per-CMM folder so they can be staged on PXE and
|
|
restored by CMM machine-# at imaging.
|
|
|
|
Run as ADMINISTRATOR on the live CMM. Do NOT run on DODA bays (handled separately).
|
|
|
|
Output: C:\Logs\CMM\cmm-backup\<CmmId>\
|
|
gocmm_backup_<PC>_<ts>.zip
|
|
pcdmis_backup_<PC>_<ver>_<ts>.zip (one per PC-DMIS version)
|
|
cmm-backup-index.json
|
|
|
|
Params:
|
|
-CmmId <id> e.g. CMM3 - names the folder + index (default: computer name)
|
|
-OutDir <p> base output folder (default C:\Logs\CMM\cmm-backup)
|
|
#>
|
|
param(
|
|
[string]$CmmId,
|
|
[string]$OutDir = 'C:\Logs\CMM\cmm-backup'
|
|
)
|
|
$ErrorActionPreference = 'Continue'
|
|
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
|
|
$ts = Get-Date -Format 'yyyyMMdd-HHmmss'
|
|
if (-not $CmmId) { $CmmId = $env:COMPUTERNAME }
|
|
$dest = Join-Path $OutDir $CmmId
|
|
New-Item -ItemType Directory -Path $dest -Force -ErrorAction SilentlyContinue | Out-Null
|
|
$log = Join-Path $dest "cmm-backup-$ts.log"
|
|
function Log($m){ Write-Host $m; $m | Out-File -FilePath $log -Append }
|
|
|
|
Log "================ CMM backup: $CmmId on $env:COMPUTERNAME at $(Get-Date) ================"
|
|
|
|
foreach ($s in 'Backup-goCMMSettings.ps1','Backup-PCDMISSettings.ps1') {
|
|
$p = Join-Path $here $s
|
|
if (-not (Test-Path $p)) { Log "MISSING sibling script: $p - skipping"; continue }
|
|
Log "---- running $s ----"
|
|
try { & $p -OutDir $dest *>&1 | ForEach-Object { Log " $_" } }
|
|
catch { Log " ERROR in $s : $($_.Exception.Message)" }
|
|
}
|
|
|
|
# index of what we captured
|
|
$zips = Get-ChildItem $dest -Filter '*.zip' -File -ErrorAction SilentlyContinue
|
|
[pscustomobject]@{
|
|
CmmId = $CmmId
|
|
Computer = $env:COMPUTERNAME
|
|
Timestamp = (Get-Date -Format o)
|
|
goCMM = @($zips | Where-Object { $_.Name -like 'gocmm_backup_*' } | Select-Object -Expand Name)
|
|
PCDMIS = @($zips | Where-Object { $_.Name -like 'pcdmis_backup_*' } | Select-Object -Expand Name)
|
|
} | ConvertTo-Json | Out-File (Join-Path $dest 'cmm-backup-index.json') -Encoding ascii
|
|
|
|
Log "================ DONE ================"
|
|
Log "Folder: $dest"
|
|
$zips | ForEach-Object { Log (" {0} ({1} KB)" -f $_.Name, [math]::Round($_.Length/1KB)) }
|
|
Write-Host ""
|
|
Write-Host "CMM backup for $CmmId complete:" -ForegroundColor Green
|
|
Write-Host " $dest"
|
|
$zips | ForEach-Object { Write-Host " $($_.Name)" }
|