HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall ----- # Lấy tất cả các khóa con trong HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall $uninstallKeyPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" $uninstallKeys = Get-ChildItem -Path $uninstallKeyPath # Lặp qua từng khóa và kiểm tra tên hoặc giá trị có liên quan đến SQL Server foreach ($key in $uninstallKeys) { $keyPath = $key.PSPath $displayName = Get-ItemProperty -Path $keyPath -Name "DisplayName" -ErrorAction SilentlyContinue if ($displayName -and $displayName.DisplayName -match "SQL Server") { Write-Host "Deleting: $keyPath" Remove-Item -Path $keyPath -Recurse -Force } } ----- # Đường dẫn đến khóa Uninstall $uninstallKeyPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" # Lấy tất cả các khóa con trong đường dẫn Uninstall $uninstallKeys = Get-ChildItem -Path $uninstallKeyPath # Tạo danh sách để lưu các khóa liên quan đến SQL Server $sqlKeys = @() # Lặp qua từng khóa và kiểm tra tên hoặc giá trị có liên quan đến SQL Server foreach ($key in $uninstallKeys) { $keyPath = $key.PSPath $displayName = Get-ItemProperty -Path $keyPath -Name "DisplayName" -ErrorAction SilentlyContinue if ($displayName -and $displayName.DisplayName -match "SQL Server") { # Thêm khóa liên quan đến SQL Server vào danh sách $sqlKeys += $displayName.DisplayName } } # Hiển thị danh sách các khóa liên quan đến SQL Server Write-Host "Các mục liên quan đến SQL Server cần kiểm tra:" $sqlKeys | ForEach-Object { Write-Host $_ } # Hiển thị tổng số lượng các khóa SQL Server tìm thấy Write-Host "Tổng số lượng mục SQL Server tìm thấy: $($sqlKeys.Count)" ----- # Đường dẫn đến khóa Uninstall $uninstallKeyPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" # Lấy tất cả các khóa con trong đường dẫn Uninstall $uninstallKeys = Get-ChildItem -Path $uninstallKeyPath # Tạo danh sách để lưu các khóa liên quan đến SQL Server $sqlKeys = @() # Lặp qua từng khóa và kiểm tra tên hoặc giá trị có liên quan đến SQL Server foreach ($key in $uninstallKeys) { $keyPath = $key.PSPath $displayName = Get-ItemProperty -Path $keyPath -Name "DisplayName" -ErrorAction SilentlyContinue if ($displayName -and $displayName.DisplayName -match "SQL Server") { # Thêm khóa liên quan đến SQL Server vào danh sách $sqlKeys += $key.PSChildName } } # Hiển thị danh sách các khóa liên quan đến SQL Server Write-Host "Các mục liên quan đến SQL Server cần kiểm tra:" $sqlKeys | ForEach-Object { Write-Host $_ } # Xóa các mục liên quan đến SQL Server foreach ($sqlKey in $sqlKeys) { $keyPathToRemove = "$uninstallKeyPath\$sqlKey" Write-Host "Đang xóa: $keyPathToRemove" Remove-Item -Path $keyPathToRemove -Recurse -Force } Write-Host "Đã xóa tất cả các mục liên quan đến SQL Server." ----- ----- ----- HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services ----- Get-ChildItem -Path "HKLM:\SYSTEM\CurrentControlSet\Services" | Where-Object { $_.PSChildName -like "*SQL*" } ----- PS C:\WINDOWS\system32> Get-ChildItem -Path "HKLM:\SYSTEM\CurrentControlSet\Services" | Where-Object { $_.PSChildName -like "*SQL*" } >> Hive: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services Name Property ---- -------- .NET Data Provider for SqlServer ----- Remove-Item -Path "HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\.NET Data Provider for SqlServer" -Recurse