{"id":28527450,"url":"https://github.com/adnervl/win2update","last_synced_at":"2026-01-28T09:37:54.570Z","repository":{"id":295130818,"uuid":"986586431","full_name":"AdnerVL/Win2Update","owner":"AdnerVL","description":"Update Windows, apps and firmware from a script file ","archived":false,"fork":false,"pushed_at":"2025-11-25T21:23:27.000Z","size":107,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-29T01:49:05.178Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AdnerVL.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-05-19T20:42:47.000Z","updated_at":"2025-11-25T21:23:30.000Z","dependencies_parsed_at":"2025-05-23T20:21:15.552Z","dependency_job_id":"918d15a6-e23b-4da4-8edf-c647bb9b4fa7","html_url":"https://github.com/AdnerVL/Win2Update","commit_stats":null,"previous_names":["adnervl/win2update"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/AdnerVL/Win2Update","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdnerVL%2FWin2Update","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdnerVL%2FWin2Update/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdnerVL%2FWin2Update/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdnerVL%2FWin2Update/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AdnerVL","download_url":"https://codeload.github.com/AdnerVL/Win2Update/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdnerVL%2FWin2Update/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28843964,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-28T07:39:25.367Z","status":"ssl_error","status_checked_at":"2026-01-28T07:39:24.487Z","response_time":57,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-09T12:13:30.647Z","updated_at":"2026-01-28T09:37:54.563Z","avatar_url":"https://github.com/AdnerVL.png","language":"PowerShell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Windows Remote Update Script\r\n\r\nA PowerShell script for automating Windows Updates on multiple remote computers using PsExec.\r\n\r\n## Requirements\r\n\r\n- Windows with PowerShell 7.0 or higher\r\n- Administrator privileges\r\n- PsExec.exe or PsExec64.exe\r\n- SMB access to target machines (port 445)\r\n- Target machines must be pingable\r\n- .NET COM objects support for Windows Update API\r\n\r\n## 📋 Prerequisites\r\n\r\n- Windows operating system\r\n- PowerShell 7.0 or later\r\n- Administrator privileges (required to run script)\r\n- PsExec.exe or PsExec64.exe in the script directory\r\n- SMB access to target machines (port 445)\r\n- Target machines must be accessible via ping\r\n- Remote machines must have Windows Update service available\r\n\r\n## � Required Files\r\n\r\n- `AdvancedRemoteUpdate.ps1`: Main script\r\n- `PsExec.exe` or `PsExec64.exe`: Required for remote execution\r\n- `hosts.txt`: List of target computers (one hostname per line)\r\n- `hosts_tracking.yaml`: Tracks update history (auto-created if missing)\r\n- `hostQueue.txt`: Manages retry queue (auto-created if missing)\r\n\r\n## ⚙️ Script Parameters\r\n\r\n| Parameter | Type | Default | Description |\r\n|-----------|------|---------|-------------|\r\n| HostsFile | string | hosts.txt | Path to file containing target hostnames (one per line) |\r\n| YamlFile | string | hosts_tracking.yaml | Path to YAML tracking file for update history |\r\n| QueueFile | string | hostQueue.txt | Path to queue management file for failed hosts |\r\n| SkipDays | int | 5 | Skip hosts successfully updated within this many days (0-365) |\r\n| ThrottleLimit | int | 10 | Maximum parallel hosts to process simultaneously (1-50) |\r\n| QueueDuration | int | 3600 | Retry wait time in seconds for queued hosts (default: 1 hour, 0-86400) |\r\n\r\n## � Usage Examples\r\n\r\n### Basic Usage\r\n\r\n```powershell\r\n.\\AdvancedRemoteUpdate.ps1\r\n```\r\n\r\n### With Custom Parameters\r\n\r\n```powershell\r\n.\\AdvancedRemoteUpdate.ps1 -HostsFile \"custom_hosts.txt\" -SkipDays 7 -AutoReboot\r\n```\r\n\r\n### With Custom Throttle Limit\r\n\r\n```powershell\r\n.\\AdvancedRemoteUpdate.ps1 -ThrottleLimit 5 # Process 5 hosts in parallel\r\n```\r\n\r\n### With Custom Queue Duration\r\n\r\n```powershell\r\n.\\AdvancedRemoteUpdate.ps1 -QueueDuration 7200 # 2 hours retry wait\r\n```\r\n\r\n### Combining Multiple Parameters\r\n\r\n```powershell\r\n.\\AdvancedRemoteUpdate.ps1 -SkipDays 7 -ThrottleLimit 15 -QueueDuration 1800\r\n```\r\n\r\n## � Tracking and Logging\r\n\r\n### YAML Tracking\r\nThe script maintains a YAML file (`hosts_tracking.yaml`) with the following information for each host:\r\n- Last connection timestamp\r\n- Last successful update timestamp\r\n- Update success status\r\n\r\nExample:\r\n\r\n```yaml\r\nsystems:\r\n- hostname: SERVER01\r\n  last_connection_timestamp: 2025-10-03T10:00:00Z\r\n  last_successful_update_timestamp: 2025-10-03T10:30:00Z\r\n  update_success: true\r\n```\r\n\r\n### Logging\r\n- Detailed logs are stored in `.logs/update_script.log`\r\n- Includes timestamps, log levels, and host-specific information\r\n- Color-coded console output for better visibility\r\n\r\n## 🔄 Queue Management\r\n\r\nThe script implements a sophisticated queue management system:\r\n\r\n- Failed or unreachable hosts are automatically added to retry queue\r\n- Default retry window is 1 hour (configurable via `QueueDuration`)\r\n- Queue status is displayed in execution summary with retry times\r\n- Queue file (`hostQueue.txt`) persists between runs\r\n- Hosts remain in queue until retry duration expires\r\n- Queue entries are automatically cleaned when expired\r\n\r\n\r\n## ✅ Execution Summary\r\n\r\nAfter each run, the script displays a comprehensive summary:\r\n\r\n```\r\n========================================\r\nEXECUTION SUMMARY\r\n========================================\r\nTotal Hosts:    50\r\nSuccessful:     45         (Green)\r\nSkipped:        3          (Yellow)\r\nFailed:         2          (Red)\r\nErrors:         0          (Red)\r\nQueued:         2          (Yellow)\r\n\r\nHosts in retry queue:\r\n  SERVER-FAIL-01 - retry in 45 minutes\r\n  SERVER-FAIL-02 - retry in 45 minutes\r\n```\r\n\r\n**Status Explanations:**\r\n- **Successful**: Update completed successfully\r\n- **Skipped-Queue**: Host in retry queue, skipped this run\r\n- **Skipped-RecentUpdate**: Host updated within SkipDays threshold\r\n- **Failed**: Update attempt failed, added to queue\r\n- **Error**: Processing error occurred\r\n- Failed updates count\r\n- Unreachable hosts count\r\n- Current queue status with retry times\r\n\r\n## 🛡️ Security Considerations\r\n\r\n1. Must run as Administrator\r\n\r\n2. Target machines must have:\r\n   - Network connectivity (ping)\r\n   - SMB (port 445) accessible\r\n   - Remote administrative access\r\n\r\n3. File security:\r\n   - PsExec.exe/PsExec64.exe in script directory\r\n   - Proper file permissions\r\n   - Secure log storage\r\n\r\n4. Network security:\r\n   - Use in trusted networks only\r\n   - Monitor remote connections\r\n   - Review execution logs\r\n\r\n## ⚠️ Important Notes\r\n\r\n1. Script Behavior:\r\n   - 10-minute timeout per host update\r\n   - Automatic directory creation (`.logs` folder)\r\n   - Built-in YAML handling (no external modules needed)\r\n   - Thread-safe parallel processing with mutex locks\r\n\r\n2. Error Handling:\r\n   - Failed hosts are queued for retry\r\n   - Detailed error logging to `.logs/update_script.log`\r\n   - Color-coded console output for visibility\r\n   - Comprehensive exception handling\r\n\r\n3. Performance:\r\n   - Parallel host processing (configurable throttle limit)\r\n   - Configurable retry intervals\r\n   - Smart update skipping based on history\r\n   - Pre-filtering for connectivity and recent updates\r\n\r\n## 🔧 Best Practices\r\n\r\n1. Host Management:\r\n   - Keep `hosts.txt` updated with valid hostnames\r\n   - Remove unreachable or decommissioned hosts\r\n   - Review queue periodically for persistent failures\r\n   - Test connectivity before running on all hosts\r\n\r\n2. Maintenance:\r\n   - Monitor `.logs/update_script.log` for growth\r\n   - Backup `hosts_tracking.yaml` periodically\r\n   - Archive old logs to prevent disk space issues\r\n   - Keep hosts.txt and tracking files synchronized\r\n\r\n3. Deployment:\r\n   - Test in small groups first (use SkipDays to prevent repeated runs)\r\n   - Start with default ThrottleLimit and adjust based on network capacity\r\n   - Monitor initial runs to understand queue dynamics\r\n   - Schedule runs during maintenance windows\r\n\r\n4. Queue Management:\r\n   - Review queued hosts in execution summary\r\n   - Investigate persistent failures\r\n   - Adjust QueueDuration if needed (e.g., increase for WAN connections)\r\n   - Clear queue file if needed: `@{} | Out-File hostQueue.txt`\r\n\r\n## 📚 Troubleshooting\r\n\r\n### Common Issues and Solutions:\r\n\r\n1. **Connection Failures:**\r\n   - Verify network connectivity: `ping \u003chostname\u003e`\r\n   - Check SMB port 445: `Test-NetConnection -ComputerName \u003chostname\u003e -Port 445`\r\n   - Validate target hostname spelling\r\n   - Check firewall rules on target machine\r\n   - Verify you have network access to target subnet\r\n\r\n2. **Update Failures:**\r\n   - Check Windows Update service: `Get-Service -Name wuauserv`\r\n   - Review error logs in `.logs/update_script.log`\r\n   - Verify administrative access to target machine\r\n   - Check target machine disk space\r\n   - Ensure Windows Update service is running\r\n\r\n3. **Queue Issues:**\r\n   - Clear queue file: `Clear-Content hostQueue.txt` or delete and recreate\r\n   - Adjust retry duration: increase QueueDuration for WAN/slow networks\r\n   - Monitor queue growth: check `hostQueue.txt` for persistence\r\n   - Review persistent failures in hosts_tracking.yaml\r\n\r\n4. **PowerShell Version:**\r\n   - Verify you're running PS 7.0+: `$PSVersionTable.PSVersion`\r\n   - Script requires PowerShell 7.0 or higher\r\n   - Not compatible with Windows PowerShell (5.1)\r\n\r\n5. **PsExec Issues:**\r\n   - Ensure `PsExec.exe` or `PsExec64.exe` is in script directory\r\n   - Run script as Administrator\r\n   - Check that PsExec hasn't been quarantined by antivirus\r\n   - EULA acceptance is automatic with `-accepteula` flag\r\n\r\n6. **Permission Errors:**\r\n   - Run script with `Run as Administrator`\r\n   - Verify target machine admin credentials/access\r\n   - Check SMB share permissions\r\n   - Verify local admin rights on target machine\r\n\r\n\r\n## 🛠️ Implementation Details\r\n\r\n### Update Process on Remote Host:\r\n1. Windows Update service validation\r\n2. Update session creation via COM objects\r\n3. Search for available updates\r\n4. Download and installation\r\n5. Group Policy update (`gpupdate /force`)\r\n6. WinGet installation (if not present)\r\n7. WinGet package upgrade\r\n8. Status tracking and reporting\r\n\r\n### Error Handling:\r\n- Connection timeouts (10-minute limit per host)\r\n- SMB port 445 connectivity checks\r\n- Windows Update service availability\r\n- Update discovery and download failures\r\n- Installation errors\r\n- Network connection issues\r\n\r\n### Parallel Processing:\r\n- Thread-safe logging with mutex locks\r\n- Configurable throttle limit (1-50 hosts)\r\n- Proper variable scoping using `$using:`\r\n- Host-specific error isolation\r\n- Automatic queue management for failures\r\n\r\n### Logging System:\r\n- Structured timestamp format (ISO 8601 UTC)\r\n- Color-coded console output (Green=Success, Red=Error, Yellow=Warning)\r\n- Centralized log file in `.logs/update_script.log`\r\n- Thread-safe file writes\r\n- Both console and file logging\r\n\r\n## 🤖 Automatic Features\r\n\r\n1. Environment Setup:\r\n   - Log directory creation (`.logs`)\r\n   - YAML file initialization (if missing)\r\n   - Queue file initialization (if missing)\r\n   - PsExec executable detection\r\n   - PowerShell version validation (7.0+)\r\n\r\n2. Host Management:\r\n   - Connection verification via ping\r\n   - Update history tracking\r\n   - Automatic queue management\r\n   - Status monitoring and reporting\r\n   - Sequential pre-filtering for connectivity\r\n\r\n3. Update Process:\r\n   - Service validation on remote machine\r\n   - Update discovery via COM objects\r\n   - Download management\r\n   - Installation tracking\r\n   - WinGet installation and upgrade\r\n   - Group Policy refresh\r\n   - Automatic reboot detection\r\n\r\n4. Queue Management:\r\n   - Automatic addition of failed hosts\r\n   - Timestamp-based retry management\r\n   - Automatic cleanup of expired entries\r\n   - Persistence across script runs\r\n\r\n## 📄 License\r\n\r\nThis project is provided as-is, without warranty. Use at your own risk.\r\n\r\n## 🔄 Contributing\r\n\r\nContributions are welcome! Please follow security best practices when submitting changes.\r\n\r\n---\r\nLast updated: November 13, 2025\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadnervl%2Fwin2update","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadnervl%2Fwin2update","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadnervl%2Fwin2update/lists"}