2
0
tcse-deploy/Login/Disable-EdgeStartup.ps1
2024-12-09 21:16:35 -06:00

28 lines
1.2 KiB
PowerShell

# Get the registry key where startup programs are stored
$registryKey = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run"
# Get all registry values (not child items) from the Run key
$edgeEntries = Get-ItemProperty -Path $registryKey |
Get-Member -MemberType NoteProperty |
Where-Object { $_.Name -like "MicrosoftEdgeAutoLaunch_*" }
# Check if any Edge entries were found
if ($edgeEntries) {
foreach ($edgeEntry in $edgeEntries) {
try {
# Remove the registry value
Remove-ItemProperty -Path $registryKey -Name $edgeEntry.Name
# Verify removal
$checkRemoval = Get-ItemProperty -Path $registryKey -Name $edgeEntry.Name -ErrorAction SilentlyContinue
if ($null -eq $checkRemoval) {
Write-Host "Microsoft Edge startup entry removed: $($edgeEntry.Name)"
} else {
Write-Warning "Failed to remove Microsoft Edge startup entry: $($edgeEntry.Name)"
}
} catch {
Write-Warning "Error removing Microsoft Edge startup entry: $($_.Exception.Message)"
}
}
} else {
Write-Warning "No Microsoft Edge startup entries found. Please manually verify the registry key."
}