From bb51a7ef90979be6d842333d97182eb8a24c6811 Mon Sep 17 00:00:00 2001 From: MyDrift Date: Thu, 8 Aug 2024 21:24:59 +0200 Subject: [PATCH] error handling --- functions/private/Uninstall-WinUtilEdgeBrowser.ps1 | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/functions/private/Uninstall-WinUtilEdgeBrowser.ps1 b/functions/private/Uninstall-WinUtilEdgeBrowser.ps1 index da313558..86eb949d 100644 --- a/functions/private/Uninstall-WinUtilEdgeBrowser.ps1 +++ b/functions/private/Uninstall-WinUtilEdgeBrowser.ps1 @@ -117,10 +117,15 @@ Function Uninstall-WinUtilEdgeBrowser { function Install-Edge { $tempEdgePath = "$env:TEMP\MicrosoftEdgeSetup.exe" - write-host "Installing Edge" - Invoke-WebRequest -Uri "https://go.microsoft.com/fwlink/?linkid=2109047&Channel=Stable&language=en&consent=1" -OutFile $tempEdgePath - Start-Process -FilePath $tempEdgePath -ArgumentList "/silent /install" -Wait - Remove-item $tempEdgePath + try { + write-host "Installing Edge" + Invoke-WebRequest -Uri "https://go.microsoft.com/fwlink/?linkid=2109047&Channel=Stable&language=en&consent=1" -OutFile $tempEdgePath + Start-Process -FilePath $tempEdgePath -ArgumentList "/silent /install" -Wait + Remove-item $tempEdgePath + write-host "Edge Installed Successfully" + } catch { + write-host "Failed to install Edge" + } } if ($action -eq "Install") {