Skip to content

Commit

Permalink
Merge pull request #45 from AshleyHow/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
AshleyHow authored Jul 3, 2024
2 parents 51b893e + ff61dfb commit 5981fff
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 47 deletions.
77 changes: 30 additions & 47 deletions Public/Get-LatestOSBuild.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -161,33 +161,16 @@
Return $ArrayList
}

Function Get-ChromeUserAgent {
# Define the URL to fetch the latest Chrome version
$LatestChromeUserAgentURL = "https://www.whatismybrowser.com/guides/the-latest-user-agent/chrome"

# Send a GET request to the URL and parse the HTML
$LatestChromeUserAgentResponse = Invoke-WebRequest -Uri $LatestChromeUserAgentURL -UseBasicParsing -ErrorAction SilentlyContinue
$HTMLLatestChromeUserAgent = $LatestChromeUserAgentResponse.Content

# Extract the latest Chrome version from the HTML
$RegexPattern = 'Chrome/([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)'
$ChromeUserAgentLatestVersion = [regex]::Match($HTMLLatestChromeUserAgent, $RegexPattern).Groups[1].Value

# Construct the user agent string
$UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/$($ChromeUserAgentLatestVersion) Safari/537.36"
Return $UserAgent
}

# Obtain data from webpage
Try {
If ($OSName -eq "Server2022" -or $OSName -eq "Server2022Hotpatch") {
$Webpage = Invoke-WebRequest -Uri $URL -UseBasicParsing -UserAgent $(Get-ChromeUserAgent) -ErrorAction Stop
$Webpage = Invoke-WebRequest -Uri $URL -UseBasicParsing -ErrorAction Stop
}
Else {
$Webpage = Invoke-RestMethod -Uri $URL -UseBasicParsing -UserAgent $(Get-ChromeUserAgent) -ErrorAction Stop
$Webpage = Invoke-RestMethod -Uri $URL -UseBasicParsing -ErrorAction Stop

# Fetch the Atom feed content, used to obtain preview and out-of-band data
$response = Invoke-WebRequest -Uri $AtomFeedUrl -Method Get -UseBasicParsing -UserAgent $(Get-ChromeUserAgent) -ErrorAction Stop
$response = Invoke-WebRequest -Uri $AtomFeedUrl -Method Get -UseBasicParsing -ErrorAction Stop

# Extract raw content from the response
$feedContent = $response.Content
Expand Down Expand Up @@ -250,7 +233,7 @@
# Support for Hotpatch
If ($null -eq $Update.OSBuild) {
Try {
$UpdateURLWebpage = Invoke-WebRequest -Uri $Update.InfoURL -UseBasicParsing -UserAgent $(Get-ChromeUserAgent) -ErrorAction Stop
$UpdateURLWebpage = Invoke-WebRequest -Uri $Update.InfoURL -UseBasicParsing -ErrorAction Stop
}
Catch {
If ($_.Exception.Message -like '*403*') {
Expand Down Expand Up @@ -536,8 +519,8 @@
# SIG # Begin signature block
# MIImcgYJKoZIhvcNAQcCoIImYzCCJl8CAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB
# gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR
# AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQUCg43FFo1CCU15BwZJslO3SiK
# JUWggiAtMIIFjTCCBHWgAwIBAgIQDpsYjvnQLefv21DiCEAYWjANBgkqhkiG9w0B
# AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQUpZ6YZcA8LaGkTBvew5MhY0z+
# N/yggiAtMIIFjTCCBHWgAwIBAgIQDpsYjvnQLefv21DiCEAYWjANBgkqhkiG9w0B
# AQwFADBlMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYD
# VQQLExB3d3cuZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVk
# IElEIFJvb3QgQ0EwHhcNMjIwODAxMDAwMDAwWhcNMzExMTA5MjM1OTU5WjBiMQsw
Expand Down Expand Up @@ -713,31 +696,31 @@
# QS4xJDAiBgNVBAMTG0NlcnR1bSBDb2RlIFNpZ25pbmcgMjAyMSBDQQIQeAuTgzem
# d0ILREkKU+Yq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jBznJ/eYX4/MBIA
# qGnAmllqik0eb6CP08uu4HMSXYHnEozpMCkvSsfkCp88MSnqNncIwqjuL6K6Y0NF
# GPmgrDKlBPikYggHGmpW6FaB+dDE1difSUuj1/OFqcEsKAPlYwrl6rPGT8WBzNAE
# 3liz4PKd
# SIG # End signature block
Binary file modified WindowsOSBuild.psd1
Binary file not shown.

0 comments on commit 5981fff

Please sign in to comment.