From 32ec95b8a0fd1074bd7db199caa76031acc98433 Mon Sep 17 00:00:00 2001 From: Joey Maffiola <7maffiolajoey@gmail.com> Date: Mon, 29 Dec 2025 08:10:01 -0600 Subject: [PATCH 01/31] Deleted ISSUE_CHECK.md --- ISSUE_CHECK.md | 136 ------------------------------------------------- 1 file changed, 136 deletions(-) delete mode 100644 ISSUE_CHECK.md diff --git a/ISSUE_CHECK.md b/ISSUE_CHECK.md deleted file mode 100644 index b635bfd..0000000 --- a/ISSUE_CHECK.md +++ /dev/null @@ -1,136 +0,0 @@ -# Issue Check Review - issueCheck Branch - -## Overview - -This document tracks the status of all open issues to determine which can be closed after the recent Publish-SFACertificates work. - -## Open Issues (7 total) - -### 1. ✅ #61 - Add edge case testing for Publish-SFACertificates - -- **Status**: ✅ CLOSED -- **Closed by**: PR #63 - Edge case testing (merged into feat/Publish-SFACertificates) -- **Key commits**: `1c8d03b`, `8dde74a`, `34fe65c`, `9921ef7` -- **Tests Added**: 76+ comprehensive edge case tests -- **Coverage**: - - ✅ Expired certificates - - ✅ Special characters in names - - ✅ Archive folder filtering - - ✅ Long filenames - - ✅ Mixed case branch codes - - ✅ Missing/malformed mappings - - ✅ Duplicate certificate names - - ✅ Report generation - -### 2. ⏳ #50 - Debug SFA Certificate Distribution Issues - -- **Status**: PARTIALLY COMPLETE -- **Phases**: - - ✅ Phase 1: Setup & Prerequisites - - ✅ Phase 2: Core Feature Verification - - ✅ Phase 3: Common Failure Scenarios - - ✅ Phase 4: Edge Cases (via #61) - - ✅ Phase 5: Integration & Validation -- **Sub-Issues**: #61, #64, #65 -- **Action**: **KEEP OPEN** - Parent issue with sub-issues #64 and #65 still pending - -### 3. 🆕 #65 - Run cleanup on local SFA source before publishing certificates - -- **Status**: 🚀 PLANNING / IN PROGRESS -- **Branch**: `feat/local-cert-cleanup-preprocessing` (created) -- **Implementation Plan**: [Posted as comment on issue #65](https://github.com/J-MaFf/PowerShellScripts/issues/65#issuecomment-3647594547) -- **Key Features**: - - ✅ Run Move-ExpiredUserCertificates on local source BEFORE publishing - - ✅ Prevent expired certs from being distributed - - ✅ Still run remote cleanup as safety net - - ✅ Track and report cleanup warnings -- **Requirements**: - - [ ] `Invoke-LocalSourceCleanup` function implemented - - [ ] Local cleanup invoked at script start - - [ ] Cleanup warnings tracked and reported - - [ ] Report generation includes local results - - [ ] 5 unit tests added and passing - - [ ] Manual integration test passed - - [ ] PR created and ready for review -- **Impact**: Workflow improvement - prevents bad data distribution -- **Effort**: Medium - -### 4. 🆕 #64 - Skip already-present certificates on remote branches - -- **Status**: 🚀 PLANNING / IN PROGRESS -- **Branch**: `feat/skip-present-certificates` (created) -- **Implementation Plan**: [Posted as comment on issue #64](https://github.com/J-MaFf/PowerShellScripts/issues/64#issuecomment-3647595988) -- **Key Features**: - - ✅ Check remote filesystem before copying - - ✅ Skip certificates already present - - ✅ Compare by filename only (no hash validation) - - ✅ Log skipped in reports - - ✅ Reduce network traffic (90%+ on subsequent runs) -- **Requirements**: - - [ ] `Test-RemoteCertificateExists` function implemented - - [ ] Skip logic integrated into copy loop - - [ ] Skipped count tracked in metrics - - [ ] Report generation includes skip stats - - [ ] 7 unit tests added and passing - - [ ] Manual integration test passed - - [ ] Performance test validates reduction - - [ ] PR created and ready for review -- **Prerequisite**: #65 (local cleanup preprocessing) -- **Impact**: Performance optimization - significant traffic reduction on subsequent runs -- **Effort**: Medium -- **Performance**: 90%+ traffic reduction after first run, 50%+ faster execution - -### 5. ❌ #56 - Archive folder being copied to remote - -- **Status**: ✅ CLOSED -- **Closed by**: Commit `5315770` - Fix archive folder name from 'Archive' to 'Old' -- **Merged into**: PR #66 - Complete Publish-SFACertificates implementation -- **Root cause**: Archive folder structure created even though files excluded -- **Fix**: Changed folder name from 'Archive' to 'Old', aligned with Move-ExpiredUserCertificates -- **Verified by**: PR #63 - Comprehensive archive folder filtering tests - -### 6. 📚 #55 - Add comprehensive tests for 1Password credential management in PersonalUtils - -- **Status**: NOT IMPLEMENTED -- **Requirements**: - - [ ] Add unit/integration tests for PersonalUtils 1Password functions - - [ ] Cover credential retrieval, error handling, CLI availability - - [ ] Test interactions with DPAPI caching - - [ ] Ensure tests are stable and don't leak secrets -- **Scope**: PersonalUtils module testing -- **Action**: **KEEP OPEN** - Separate from SFA work, needs own effort - -### 7. 💾 #34 - 1Password CLI Service Account Limitation with DateFormat Scripts - -- **Status**: IN PROGRESS (feat/1password-credential-management branch) -- **Proposed**: Credential file cache with DPAPI encryption -- **Impact**: DateFormat scripts usability enhancement -- **Action**: **KEEP OPEN** - Active development on separate branch - ---- - -## Summary - -### Issues Closed (2) ✅ - -- ✅ #61 - Edge case testing (PR #63, merged) -- ✅ #56 - Archive folder bug (Commit 5315770, merged via PR #66) - -### Issues in Planning/Development (2) 🚀 - -- 🚀 #65 - Local cleanup preprocessing (`feat/local-cert-cleanup-preprocessing`) - - Implementation plan: Posted on issue - - Expected: Medium effort, high impact - - Status: Ready to implement - -- 🚀 #64 - Skip present certificates (`feat/skip-present-certificates`) - - Implementation plan: Posted on issue - - Expected: Medium effort, performance boost - - Status: Depends on #65, ready when #65 complete - - Performance: 90%+ traffic reduction on subsequent runs - -### Issues in Different Scope (3) 📚 - -- 📚 #55 - 1Password PersonalUtils tests (separate scope) -- 📚 #34 - 1Password credential management (separate scope) -- 📚 #50 - Parent tracking issue (depends on #64, #65) From becae98e400f99394d1f90b5adc4759fe501a4a6 Mon Sep 17 00:00:00 2001 From: Joey Maffiola <7maffiolajoey@gmail.com> Date: Mon, 29 Dec 2025 08:31:10 -0800 Subject: [PATCH 02/31] fix: Enforce PowerShell Core requirement and add auto-redirect for Windows PowerShell --- Scripts/SFA/Publish-SFACertificates.ps1 | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/Scripts/SFA/Publish-SFACertificates.ps1 b/Scripts/SFA/Publish-SFACertificates.ps1 index 17dc894..37444e1 100644 --- a/Scripts/SFA/Publish-SFACertificates.ps1 +++ b/Scripts/SFA/Publish-SFACertificates.ps1 @@ -1,4 +1,20 @@ #Requires -Version 5.1 +#Requires -PSEdition Core + +# ============================================================================ +# PowerShell Version Check and Auto-Redirect +# ============================================================================ +# This script requires PowerShell Core (pwsh) due to UTF-8 emoji support. +# If running on Windows PowerShell, automatically re-invoke with pwsh. + +if ($PSVersionTable.PSEdition -eq 'Desktop') { + Write-Host "⚠️ This script requires PowerShell Core. Re-invoking with pwsh..." -ForegroundColor Yellow + $pwshPath = 'pwsh' + $scriptPath = $PSCommandPath + $arguments = @('-NoExit', '-ExecutionPolicy', 'Bypass', '-File', $scriptPath) + $PSBoundParameters.GetEnumerator() | ForEach-Object { "-$($_.Key)", "$($_.Value)" } + & $pwshPath @arguments + exit +} <# .SYNOPSIS @@ -147,7 +163,7 @@ function Invoke-LocalSourceCleanup { # Invoke cleanup script on local source directory # Capture warnings to stream 3 - $result = & $CleanupScriptPath -TargetDirectory $LocalSourceDirectory -ErrorAction Stop 3>&1 + & $CleanupScriptPath -TargetDirectory $LocalSourceDirectory -ErrorAction Stop 3>&1 | Out-Null Write-Host "✅ Local source cleanup completed" -ForegroundColor Green return @{ Success = $true; Message = 'Local cleanup completed successfully'; Error = $null } @@ -285,7 +301,7 @@ foreach ($branchCode in $BranchMappings.Keys | Sort-Object) { $pmaiSubFolders = Get-ChildItem -Path $folder.FullName -Directory -ErrorAction SilentlyContinue foreach ($pmaiSub in $pmaiSubFolders) { # Match if subfolder name starts with the branch code (e.g., "JPM (LA)" matches "JPM") - if ($pmaiSub.Name -match "^$branchCode\s*\(|^$branchCode`$") { + if ($pmaiSub.Name -match "^$branchCode\s*\(.*\)|^$branchCode`$") { $localBranchPath = $pmaiSub.FullName $localBranchExists = $true break From 647ee31b4def634a591574a5cebc44ea02d1ee6a Mon Sep 17 00:00:00 2001 From: Joey Maffiola <7maffiolajoey@gmail.com> Date: Mon, 29 Dec 2025 08:39:29 -0800 Subject: [PATCH 03/31] docs: Add complete SFA certificate workflow documentation to README --- Scripts/SFA/README.html | 68 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 66 insertions(+), 2 deletions(-) diff --git a/Scripts/SFA/README.html b/Scripts/SFA/README.html index f8f9087..6ce627e 100644 --- a/Scripts/SFA/README.html +++ b/Scripts/SFA/README.html @@ -221,6 +221,68 @@

Overview

per-user password protection.

+

Complete SFA Certificate Workflow

+

+ This script is the first step in a three-stage SFA certificate distribution system: +

+ +
+

📋 Stage 1: Export Certificates

+

Script: Export-UserCertificates.ps1 (this script)

+

Purpose: Extract user certificates from Windows Certificate Store

+ +

Output: PFX files in exports_TIMESTAMP/ directory

+
+ +
+

📦 Stage 2: Publish to Branches

+

Script: Publish-SFACertificates.ps1

+

Purpose: Distribute exported certificates to 24 branch servers

+ +

Output: Certificates distributed to all 24 SFA branches worldwide

+
+ +
+

🧹 Stage 3: Archive Expired Certificates

+

Script: Move-ExpiredUserCertificates.ps1

+

Purpose: Automatically clean up expired certificates

+ +

Output: Archive folders with expired certificates on all systems

+
+ +

Complete Workflow Example

+
# Step 1: Export certificates from local Windows Certificate Store +.\Export-UserCertificates.ps1 +# Creates: exports_2025-12-29_143022/ with PFX files + +# Step 2: Publish to all 24 branch servers +.\Publish-SFACertificates.ps1 -LocalSourceDirectory 'C:\Users\admin-sfa\Desktop\SFA Certificates' +# Distributes PFX files to all branches and cleans up expired ones + +# The workflow is now complete - all branches have current certificates!
+

Key Features

@@ -262,7 +324,8 @@

With Username Mapping File

Remote Computer Export

Export certificates from a remote computer:

- .\Export-UserCertificates.ps1 -ComputerName 'RemotePC' -Credential (Get-Credential)
+ .\Export-UserCertificates.ps1 -ComputerName 'RemotePC' -Credential (Get-Credential) +

Custom Output Directory

Specify where to save the exported certificates:

@@ -405,7 +468,8 @@

Example 3: Remote Export with Custom Password

$cred = Get-Credential $password = ConvertTo-SecureString 'MySecurePassword' -AsPlainText -Force -.\Export-UserCertificates.ps1 -ComputerName 'RemotePC' -Credential $cred -Password $password -UseUsernameAsPassword:$false
+.\Export-UserCertificates.ps1 -ComputerName 'RemotePC' -Credential $cred -Password $password -UseUsernameAsPassword:$false +

Prerequisites