Initial commit: Organized PowerShell scripts for ShopDB asset collection

Structure:
- asset-collection/: Local PC data collection scripts
- remote-execution/: WinRM remote execution scripts
- setup-utilities/: Configuration and testing utilities
- registry-backup/: GE registry backup scripts
- winrm-https/: WinRM HTTPS certificate setup
- docs/: Complete documentation

Each folder includes a README with detailed documentation.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
cproudlock
2025-12-10 10:57:54 -05:00
commit 62c0c7bb06
102 changed files with 28017 additions and 0 deletions

View File

@@ -0,0 +1,67 @@
@echo off
REM Backup-GERegistry.bat - Wrapper for GE Aircraft Engines registry backup
REM Backs up both 32-bit and 64-bit registry locations to S:\dt\adata\script\backup
setlocal enabledelayedexpansion
echo.
echo ===============================================
echo GE Aircraft Engines Registry Backup
echo ===============================================
echo.
REM Check if running as administrator
net session >nul 2>&1
if %errorlevel% neq 0 (
echo [WARNING] Not running as administrator.
echo Registry backup may have limited access.
echo.
)
REM Set default backup path
set "BACKUP_PATH=S:\dt\adata\script\backup"
REM Check if custom path provided
if not "%~1"=="" (
set "BACKUP_PATH=%~1"
echo Using custom backup path: %BACKUP_PATH%
) else (
echo Using default backup path: %BACKUP_PATH%
)
REM Create backup directory if it doesn't exist
if not exist "%BACKUP_PATH%" (
echo Creating backup directory...
mkdir "%BACKUP_PATH%" 2>nul
if errorlevel 1 (
echo [ERROR] Failed to create backup directory
echo Please ensure S: drive is mapped and accessible
pause
exit /b 1
)
)
REM Run the PowerShell script
echo.
echo Starting registry backup...
echo -----------------------------------------------
powershell.exe -NoProfile -ExecutionPolicy Bypass -File "%~dp0Backup-GERegistry.ps1" -BackupPath "%BACKUP_PATH%"
set RESULT=%ERRORLEVEL%
echo -----------------------------------------------
echo.
if %RESULT% equ 0 (
echo [SUCCESS] Registry backup completed successfully
echo Check the backup folder: %BACKUP_PATH%
) else (
echo [INFO] No GE Aircraft Engines registry keys found or backup failed
echo This may be normal if GE software is not installed
)
echo.
echo Press any key to exit...
pause >nul
exit /b %RESULT%

View File

@@ -0,0 +1,277 @@
# Backup-GERegistry.ps1
# Backs up GE Aircraft Engines registry keys from both 32-bit and 64-bit locations
# Saves to S:\DT\cameron\scan\backup\reg with naming: [machinenumber-]serialnumber-date.reg
param(
[Parameter(Mandatory=$false)]
[string]$BackupPath = "S:\DT\cameron\scan\backup\reg",
[Parameter(Mandatory=$false)]
[switch]$Silent = $false
)
# Function to write colored output (only if not silent)
function Write-ColorOutput {
param(
[string]$Message,
[string]$Color = "White"
)
if (-not $Silent) {
Write-Host $Message -ForegroundColor $Color
}
}
# Function to get machine number from registry
function Get-MachineNumber {
$machineNumber = $null
# Check GE Aircraft Engines registry paths for MachineNo
$gePaths = @(
"HKLM:\Software\GE Aircraft Engines\DNC\General",
"HKLM:\Software\WOW6432Node\GE Aircraft Engines\DNC\General"
)
foreach ($path in $gePaths) {
if (Test-Path $path) {
try {
$regKey = Get-ItemProperty -Path $path -ErrorAction SilentlyContinue
if ($regKey.MachineNo) {
$machineNumber = $regKey.MachineNo
Write-ColorOutput " Found MachineNo in registry: $machineNumber" "Green"
break
}
}
catch {
Write-ColorOutput " Could not read MachineNo from $path" "Yellow"
}
}
}
# If not found in registry, try hostname pattern matching
if (-not $machineNumber) {
$hostname = $env:COMPUTERNAME
if ($hostname -match '(\d{4})') {
$machineNumber = $matches[1]
Write-ColorOutput " Extracted machine number from hostname: $machineNumber" "Cyan"
}
}
return $machineNumber
}
# Function to get serial number
function Get-SerialNumber {
$serialNumber = $null
try {
# Get serial number from WMI
$bios = Get-WmiObject Win32_BIOS
if ($bios.SerialNumber -and $bios.SerialNumber -ne "To be filled by O.E.M.") {
$serialNumber = $bios.SerialNumber
Write-ColorOutput " Found serial number: $serialNumber" "Green"
}
}
catch {
Write-ColorOutput " Could not retrieve serial number from BIOS" "Yellow"
}
# If no serial number, use computer name as fallback
if (-not $serialNumber) {
$serialNumber = $env:COMPUTERNAME
Write-ColorOutput " Using computer name as identifier: $serialNumber" "Cyan"
}
return $serialNumber
}
# Function to export registry key
function Export-RegistryKey {
param(
[string]$RegistryPath,
[string]$OutputFile,
[string]$Description
)
# Convert PowerShell path to reg.exe format
$regPath = $RegistryPath -replace 'HKLM:', 'HKEY_LOCAL_MACHINE'
try {
# Use reg export command
$result = reg export "$regPath" "$OutputFile" /y 2>&1
if ($LASTEXITCODE -eq 0) {
Write-ColorOutput " ✓ Exported $Description" "Green"
return $true
} else {
Write-ColorOutput " ✗ Failed to export $Description" "Red"
Write-ColorOutput " Error: $result" "Red"
return $false
}
}
catch {
Write-ColorOutput " ✗ Exception exporting $Description`: $_" "Red"
return $false
}
}
# Main script
Write-ColorOutput "`n=== GE Aircraft Engines Registry Backup ===" "Cyan"
Write-ColorOutput "Starting registry backup process..." "White"
# Get machine number and serial number
Write-ColorOutput "`nGathering system information:" "Yellow"
$machineNumber = Get-MachineNumber
$serialNumber = Get-SerialNumber
# Create backup filename
$dateStamp = Get-Date -Format "yyyyMMdd-HHmmss"
if ($machineNumber) {
$backupFileName = "${machineNumber}-${serialNumber}-${dateStamp}.reg"
} else {
$backupFileName = "${serialNumber}-${dateStamp}.reg"
}
# Create backup directory if it doesn't exist
if (-not (Test-Path $BackupPath)) {
try {
New-Item -ItemType Directory -Path $BackupPath -Force | Out-Null
Write-ColorOutput "`nCreated backup directory: $BackupPath" "Green"
}
catch {
Write-ColorOutput "`nFailed to create backup directory: $_" "Red"
exit 1
}
}
# Define registry paths to backup
$registryPaths = @{
'64bit' = @{
Path = 'HKLM:\SOFTWARE\GE Aircraft Engines'
Description = 'GE Aircraft Engines (64-bit)'
OutputFile = Join-Path $BackupPath "64bit-$backupFileName"
}
'32bit' = @{
Path = 'HKLM:\SOFTWARE\WOW6432Node\GE Aircraft Engines'
Description = 'GE Aircraft Engines (32-bit on 64-bit system)'
OutputFile = Join-Path $BackupPath "32bit-$backupFileName"
}
}
# Backup registries
Write-ColorOutput "`nBacking up GE Aircraft Engines registry keys:" "Yellow"
$backupResults = @()
foreach ($type in $registryPaths.Keys) {
$regInfo = $registryPaths[$type]
Write-ColorOutput "`n Checking $($regInfo.Description)..." "White"
if (Test-Path $regInfo.Path) {
Write-ColorOutput " Found registry key at: $($regInfo.Path)" "Green"
$success = Export-RegistryKey -RegistryPath $regInfo.Path `
-OutputFile $regInfo.OutputFile `
-Description $regInfo.Description
if ($success -and (Test-Path $regInfo.OutputFile)) {
$fileSize = (Get-Item $regInfo.OutputFile).Length
$fileSizeKB = [math]::Round($fileSize / 1KB, 2)
Write-ColorOutput (" Saved to: " + $regInfo.OutputFile + " (" + $fileSizeKB + " KB)") "Green"
$backupResults += @{
Type = $type
File = $regInfo.OutputFile
Size = $fileSizeKB
Success = $true
}
} else {
$backupResults += @{
Type = $type
File = $regInfo.OutputFile
Success = $false
}
}
} else {
Write-ColorOutput " Registry key not found: $($regInfo.Path)" "Yellow"
Write-ColorOutput " Skipping $type backup" "Yellow"
}
}
# Combined backup (both 32-bit and 64-bit in one file)
Write-ColorOutput "`nCreating combined backup:" "Yellow"
$combinedFile = Join-Path $BackupPath $backupFileName
$combinedContent = @()
# Add header
$combinedContent += "Windows Registry Editor Version 5.00"
$combinedContent += ""
$combinedContent += "; GE Aircraft Engines Registry Backup"
$combinedContent += "; Machine: $machineNumber"
$combinedContent += "; Serial: $serialNumber"
$combinedContent += "; Date: $dateStamp"
$combinedContent += "; Computer: $env:COMPUTERNAME"
$combinedContent += ""
# Merge successful backups
$mergedCount = 0
foreach ($result in $backupResults | Where-Object { $_.Success }) {
if (Test-Path $result.File) {
Write-ColorOutput " Merging $($result.Type) backup..." "White"
# Read the file and skip the header
$content = Get-Content $result.File
if ($content.Count -gt 1) {
# Skip the "Windows Registry Editor Version 5.00" line
$contentToAdd = $content | Select-Object -Skip 1
$combinedContent += "; === $($result.Type) Registry ==="
$combinedContent += $contentToAdd
$combinedContent += ""
$mergedCount++
}
}
}
if ($mergedCount -gt 0) {
try {
# Save combined file
$combinedContent | Out-File -FilePath $combinedFile -Encoding Unicode
$fileSize = (Get-Item $combinedFile).Length
$fileSizeKB = [math]::Round($fileSize / 1KB, 2)
Write-ColorOutput (" Combined backup saved: " + $combinedFile + " (" + $fileSizeKB + " KB)") "Green"
# Clean up individual files if combined was successful
foreach ($result in $backupResults | Where-Object { $_.Success }) {
if (Test-Path $result.File) {
Remove-Item $result.File -Force
Write-ColorOutput " Cleaned up temporary file: $($result.Type)" "Gray"
}
}
}
catch {
Write-ColorOutput " ✗ Failed to create combined backup: $_" "Red"
}
} else {
Write-ColorOutput " ✗ No registry keys were successfully backed up" "Red"
}
# Summary
Write-ColorOutput "`n=== Backup Summary ===" "Cyan"
Write-ColorOutput "Machine Number: $(if ($machineNumber) { $machineNumber } else { 'Not found' })" "White"
Write-ColorOutput "Serial Number: $serialNumber" "White"
Write-ColorOutput "Backup Location: $BackupPath" "White"
Write-ColorOutput "Backup File: $backupFileName" "White"
$successCount = ($backupResults | Where-Object { $_.Success }).Count
$totalCount = $backupResults.Count
if ($successCount -gt 0) {
Write-ColorOutput "`nBackup completed: $successCount of $totalCount registries backed up successfully" "Green"
} else {
Write-ColorOutput "`nNo GE Aircraft Engines registry keys found to backup" "Yellow"
}
# Return success status
exit $(if ($successCount -gt 0) { 0 } else { 1 })

104
registry-backup/README.md Normal file
View File

@@ -0,0 +1,104 @@
# Registry Backup Scripts
Scripts for backing up GE Aircraft Engines registry keys for disaster recovery and auditing.
## Scripts
### Backup-GERegistry.ps1
**GE Registry backup utility** - Backs up GE Aircraft Engines registry keys from both 32-bit and 64-bit locations.
**What it does:**
1. Reads machine number from GE registry or extracts from hostname
2. Gets serial number from BIOS
3. Exports registry keys from both locations:
- `HKLM:\Software\GE Aircraft Engines` (32-bit)
- `HKLM:\Software\WOW6432Node\GE Aircraft Engines` (64-bit)
4. Saves backup files to network share
**Usage:**
```powershell
# Interactive backup with console output
.\Backup-GERegistry.ps1
# Silent backup (for scheduled tasks)
.\Backup-GERegistry.ps1 -Silent
# Custom backup path
.\Backup-GERegistry.ps1 -BackupPath "\\server\share\backups"
```
**Parameters:**
| Parameter | Default | Description |
|-----------|---------|-------------|
| `-BackupPath` | `S:\DT\cameron\scan\backup\reg` | Network path for backup files |
| `-Silent` | `$false` | Suppress console output |
**Output Filename Format:**
```
[machinenumber-]serialnumber-YYYY-MM-DD.reg
Examples:
3104-G4B48FZ3ESF-2025-12-10.reg
7402-G9WP26X3ESF-2025-12-10.reg
```
**Registry Keys Backed Up:**
- DNC Configuration (EFOCAS, SERIAL, NTSHR, etc.)
- DualPath settings (Path1Name, Path2Name)
- Machine number assignments
- Communication settings
- All GE Aircraft Engines subkeys
---
## Batch File Launchers
| File | Purpose |
|------|---------|
| `Backup-GERegistry.bat` | Standard launcher for registry backup |
---
## Requirements
- PowerShell 5.1 or later
- Read access to registry
- Write access to backup network share
- Works without administrator privileges (registry read-only)
## Use Cases
### Manual Backup Before Changes
```powershell
# Before making registry changes, create a backup
.\Backup-GERegistry.ps1
```
### Automated Scheduled Backup
```powershell
# In scheduled task, run silently
.\Backup-GERegistry.ps1 -Silent
```
### Restore from Backup
```cmd
# Double-click the .reg file or run:
regedit /s "\\server\share\backups\3104-G4B48FZ3ESF-2025-12-10.reg"
```
## Backup Contents
The backup `.reg` file includes:
- Complete GE Aircraft Engines registry tree
- DNC service configurations
- Machine communication settings
- Serial port assignments
- DualPath configurations
- Custom GE software settings
## Important Notes
- Backups are named with machine number (if available) for easy identification
- Both 32-bit and 64-bit registry locations are exported
- Existing backups are not overwritten (date is included in filename)
- Silent mode is recommended for scheduled tasks to avoid interrupting users