$Platform = "Windows" if ((Get-WmiObject win32_operatingsystem).osarchitecture -eq "64-Bit") { $Architecture = "x64" $EdgeMSI = join-path $env:temp\edgeinstall MicrosoftEdgeEnterpriseX64.msi } else { $Architecture = "x86" $EdgeMSI = join-path $env:temp\edgeinstall MicrosoftEdgeEnterpriseX86.msi } mkdir -Path $env:temp\edgeinstall -erroraction SilentlyContinue | Out-Null $DownloadFolder = "$env:temp\edgeinstall" $edgeEnterpriseMSIUri = 'https://edgeupdates.microsoft.com/api/products?view=enterprise' $ErrorActionPreference = "Stop" $response = Invoke-WebRequest -Uri $edgeEnterpriseMSIUri -Method Get -ContentType "application/json" -UseBasicParsing -ErrorVariable InvokeWebRequestError $jsonObj = ConvertFrom-Json $([String]::new($response.Content)) #Download Latest Stable Version $selectedIndexStable = [array]::indexof($jsonObj.Product, "Stable") $latestVersion = (([Version[]](($jsonObj[$selectedIndexStable].Releases | Where-Object { $_.Architecture -eq $Architecture -and $_.Platform -eq $Platform }).ProductVersion) | Sort-Object -Descending)[0]).ToString(4) Write-Host "Latest Stable Version for Edge is $latestVersion" -ForegroundColor Green $selectedObject = $jsonObj[$selectedIndexStable].Releases | Where-Object { $_.Architecture -eq $Architecture -and $_.Platform -eq $Platform -and $_.ProductVersion -eq $latestVersion } foreach ($artifacts in $selectedObject.Artifacts) { # Not showing the progress bar in Invoke-WebRequest is quite a bit faster than default $ProgressPreference = 'SilentlyContinue' Write-host "Starting download of: $($artifacts.Location)" -ForegroundColor Green # Work out file name $fileName = Split-Path $artifacts.Location -Leaf Write-host "Writing File to: $DownloadFolder\$fileName`n" -ForegroundColor Green Invoke-WebRequest -Uri $artifacts.Location -OutFile "$DownloadFolder\$fileName" -UseBasicParsing } #Download Latest Policy Version $selectedIndexPolicy = [array]::indexof($jsonObj.Product, "Policy") $latestVersion = (([Version[]](($jsonObj[$selectedIndexPolicy].Releases | Where-Object { $_.Architecture -eq "Any" -and $_.Platform -eq "Any" }).ProductVersion) | Sort-Object -Descending)[0]).ToString(4) Write-Host "Latest Policy Version for Edge is $latestVersion" -ForegroundColor Green $selectedObject = $jsonObj[$selectedIndexPolicy].Releases | Where-Object { $_.Architecture -eq "Any" -and $_.Platform -eq "Any" -and $_.ProductVersion -eq $latestVersion } foreach ($artifacts in $selectedObject.Artifacts) { # Not showing the progress bar in Invoke-WebRequest is quite a bit faster than default $ProgressPreference = 'SilentlyContinue' Write-host "Starting download of: $($artifacts.Location)" -ForegroundColor Green # Work out file name $fileName = Split-Path $artifacts.Location -Leaf Write-host "Writing File to: $DownloadFolder\$fileName" -ForegroundColor Green Invoke-WebRequest -Uri $artifacts.Location -OutFile "$DownloadFolder\$fileName" -UseBasicParsing } Write-host "`nInstalling Latest Version of Microsoft Edge" -ForegroundColor Green Start-Process "$EdgeMSI" -ArgumentList "/quiet" # Extract the Edge Policy Files $EdgePolicyZip = join-path $env:temp\edgeinstall MicrosoftEdgePolicyTemplates.zip mkdir -Path $env:temp\edgeinstall\MicrosoftEdgePolicyTemplates -erroraction SilentlyContinue | Out-Null Expand-Archive -Path "$EdgePolicyZip" -DestinationPath "$env:temp\edgeinstall\MicrosoftEdgePolicyTemplates" -Force #Copy Edge Policy Files to correct directory Write-host "Copying Policy Files to correct directory" -ForegroundColor Green Copy-Item "$env:temp\edgeinstall\MicrosoftEdgePolicyTemplates\windows\admx\msedge.admx" -Destination "C:\Windows\PolicyDefinitions\" -Force -PassThru Get-ChildItem "$env:temp\edgeinstall\MicrosoftEdgePolicyTemplates\windows\admx\en-us\" -Filter *.adml | Copy-Item -Destination "C:\Windows\PolicyDefinitions\en-US\" -Force -PassThru #Register the sitelist Write-host "Register Internet Explorer Integration SiteList" -ForegroundColor Green $registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Edge" $ieilName = "InternetExplorerIntegrationLevel" $ieilvalue = "1" $ieislName = "InternetExplorerIntegrationSiteList" $ieislvalue = "https://saas.harmonyis.net/embedded/sams/sitelist.xml" IF(!(Test-Path $registryPath)) { New-Item -Path $registryPath -Force | Out-Null New-ItemProperty -Path $registryPath -Name $ieilName -Value $ieilvalue -PropertyType DWORD -Force | Out-Null New-ItemProperty -Path $registryPath -Name $ieislName -Value $ieislvalue -PropertyType String -Force | Out-Null } ELSE { New-ItemProperty -Path $registryPath -Name $ieilName -Value $ieilvalue -PropertyType DWORD -Force | Out-Null New-ItemProperty -Path $registryPath -Name $ieislName -Value $ieislvalue -PropertyType String -Force | Out-Null } Write-Host "-- Script Completed --" -ForegroundColor Green