{"id":26368622,"url":"https://github.com/adnervl/dotnet8remediation","last_synced_at":"2025-03-16T22:48:40.270Z","repository":{"id":282040954,"uuid":"947287317","full_name":"AdnerVL/DotNet8Remediation","owner":"AdnerVL","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-12T14:16:18.000Z","size":1,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-12T14:20:01.421Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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}},"created_at":"2025-03-12T13:00:44.000Z","updated_at":"2025-03-12T14:16:21.000Z","dependencies_parsed_at":"2025-03-12T14:20:02.799Z","dependency_job_id":"5019087d-32ba-4789-b21c-894c98e7df00","html_url":"https://github.com/AdnerVL/DotNet8Remediation","commit_stats":null,"previous_names":["adnervl/dotnet8remediation"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdnerVL%2FDotNet8Remediation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdnerVL%2FDotNet8Remediation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdnerVL%2FDotNet8Remediation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdnerVL%2FDotNet8Remediation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AdnerVL","download_url":"https://codeload.github.com/AdnerVL/DotNet8Remediation/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243945496,"owners_count":20372894,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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-03-16T22:48:39.850Z","updated_at":"2025-03-16T22:48:40.257Z","avatar_url":"https://github.com/AdnerVL.png","language":"PowerShell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# .NET 8.0 SDK Remediation via Intune with Winget\n\nThis project provides scripts to detect and remediate the absence of the .NET 8.0 SDK on Windows devices using Intune and Winget. It includes a Win32 app deployment for Winget to ensure it’s available in SYSTEM context.\n\n## Prerequisites\n\n- **Intune Access**: Administrative rights to create Win32 apps and remediation policies.\n\n- **Winget Source**: Extracted `winget.exe` and its dependencies from an installed instance.\n\n- **Test Machine**: Windows 10 1809+ or Windows 11, 64-bit.\n\n- **Tools**:\n  - `IntuneWinAppUtil.exe` (download from [Microsoft](https://github.com/microsoft/Microsoft-Win32-Content-Prep-Tool)).\n  - `PsExec` (optional, for local testing) from [Sysinternals](https://docs.microsoft.com/en-us/sysinternals/downloads/psexec).\n\n## Step 1: Extract Winget and Dependencies\n\n1. **Install Winget on a Test Machine**:\n   - Download `Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle` from [GitHub](https://github.com/microsoft/winget-cli/releases/latest).\n   - Install manually (e.g., double-click or use `Add-AppxPackage` in user context).\n\n2. **Copy Files**:\n   - Navigate to `C:\\Program Files\\WindowsApps\\Microsoft.DesktopAppInstaller_*_*` (e.g., `Microsoft.DesktopAppInstaller_2025.228.315.0_neutral_~_8wekyb3d8bbwe`).\n   - Copy all contents (e.g., `winget.exe`, `msvcp140.dll`, `vcruntime140.dll`) to a local folder, e.g., `C:\\Tools\\WingetSource`.\n\n## Step 2: Deploy Winget as a Win32 App\n\n1. **Package Winget**:\n   - Place all files from `C:\\Tools\\WingetSource` into `C:\\Tools\\Intune`.\n   - Run from `C:\\Tools\\Microsoft-Win32-Content-Prep-Tool\\Microsoft-Win32-Content-Prep-Tool-1.8.6`:\n\n     ```cmd\n     .\\IntuneWinAppUtil.exe -c C:\\Tools\\Intune -s winget.exe -o C:\\Tools\\Intune\\Out\n     ```\n\n   - Output: C:\\Tools\\Intune\\Out\\winget.intunewin.\n\n2. **Create Win32 App in Intune**:\n   - Intune: Apps \u003e All apps \u003e Add \u003e Windows app (Win32).\n   - Upload: winget.intunewin.\n   - Program:\n     - Install:\n\n     ```powershell\n      powershell.exe -ExecutionPolicy Bypass -Command \"New-Item -Path 'C:\\Tools\\winget' -ItemType Directory -Force; Copy-Item -Path '.\\*' -Destination 'C:\\Tools\\winget' -Recurse -Force\"\n      ```\n\n     - Uninstall:\n\n      ```powershell\n       powershell.exe -ExecutionPolicy Bypass -Command \"Remove-Item -Path 'C:\\Tools\\winget' -Recurse -Force\"\n      ```\n\n   - Requirements: Windows 10 1809+, 64-bit.\n   - Detection Rule:\n     - Type: File\n     - Path: C:\\Tools\\winget\n     - File: winget.exe\n     - Detection method: File or folder exists\n   - Assignments: Assign as Required to your device group (SYSTEM context).\n3. **Deploy**:\n Sync devices via Company Portal to install Winget to `C:\\Tools\\winget`.\n\n## Step 3: Prepare Remediation Scripts\n\n1. **Detection Script (Detection-net-8-sdk.ps1)**:\n\n ```powershell\n try {\n     $sdks = dotnet --list-sdks\n     if ($sdks -match \"8.0\") {\n         exit 0  # SDK found\n     } else {\n         exit 1  # SDK not found\n     }\n } catch {\n     exit 1  # Error occurred\n }\n ```\n\n2. **Remediation Script (Remediation-net-8-sdk.ps1)**:\n\n ```powershell\n Write-Output \"Starting .NET 8.0 SDK remediation...\"\n try {\n     $sdks = dotnet --list-sdks\n     if ($sdks -match \"8.0\") {\n         Write-Output \"SDK 8.0 already installed\"\n         exit 0\n     }\n } catch {\n     Write-Output \"Error checking SDK: $_\"\n }\n $wingetPath = \"C:\\Tools\\winget\\winget.exe\"\n if (-not (Test-Path $wingetPath)) {\n     Write-Error \"Winget not found at $wingetPath. Ensure Winget is deployed.\"\n     exit 1\n }\n Write-Output \"Winget located at $wingetPath\"\n Write-Output \"Installing .NET 8.0 SDK with Winget...\"\n try {\n     \u0026 $wingetPath install --id Microsoft.DotNet.SDK.8 --silent --accept-source-agreements --accept-package-agreements\n     if ($LASTEXITCODE -eq 0) {\n         Write-Output \"SDK 8.0 installed\"\n         exit 0\n     } else {\n         Write-Error \"Winget failed: $LASTEXITCODE\"\n         exit 1\n     }\n } catch {\n     Write-Error \"Install error: $_\"\n     exit 1\n }\n ```\n\n## Step 4: Deploy Remediation in Intune\n\n1. **Create Remediation**:\n\n   - Intune: Devices \u003e Scripts and remediations \u003e Remediation \u003e Create.\n   - Name: \"Install .NET 8.0 SDK\".\n   - Detection Script: Upload `Detection-net-8-sdk.ps1`.\n   - Remediation Script: Upload `Remediation-net-8-sdk.ps1`.\n   - Settings:\n      - Run as logged-on credentials: No (SYSTEM context).\n      - Enforce signature check: No.\n      - Run in 64-bit PowerShell: Yes.\n   - Assignments: Assign to your device group.\n\n2. **Sync Devices**:\n\n  Use Company Portal to sync and apply the remediation.\n\n## Step 5: Test and Verify\n\n1. Local Test:\n\n   - Run `psexec -s powershell` on a test machine.\n   - Execute: `C:\\Tools\\Git\\DotNet8Remediation\\Remediation-net-8-sdk.ps1`.\n   - Verify: `dotnet --list-sdks lists` a version like `8.0.407`.\n\n2. Intune Logs:\n\n   - Check `C:\\ProgramData\\Microsoft\\IntuneManagementExtension\\Logs\\IntuneManagementExtension.log` for execution details.\n\n## Troubleshooting\n\n- Winget Fails (-1073741515): Ensure all dependencies (e.g., `msvcp140.dll`) are included in `C:\\Tools\\WingetSource`.\n\n- Detection Errors: Confirm script names are correct in Intune (`Detection-net-8-sdk.ps1, Remediation-net-8-sdk.ps1`).\n\n- No Install: Verify Winget Win32 app deployed successfully before remediation runs.\n\n## Notes\n\n- Dependencies: `winget.exe` requires runtime DLLs from its original folder. Include all files from `Microsoft.DesktopAppInstaller_*_*`.\n\n- Version: This installs the latest .NET 8.0 SDK (e.g., 8.0.407 as of testing).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadnervl%2Fdotnet8remediation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadnervl%2Fdotnet8remediation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadnervl%2Fdotnet8remediation/lists"}