This repository was archived by the owner on Apr 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathMacOSUpdateConnectivity.psm1
68 lines (50 loc) · 2.77 KB
/
MacOSUpdateConnectivity.psm1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
Set-StrictMode -Version 4
Import-Module -Name HttpConnectivityTester -Force
# 1. import this file:
# Import-Module .\MacOSUpdateConnectivity.psm1
# 2. run one of the following:
# $connectivity = Get-MacOSUpdateConnectivity
# $connectivity = Get-MacOSUpdateConnectivity -Verbose
# $connectivity = Get-MacOSUpdateConnectivity -PerformBlueCoatLookup
# $connectivity = Get-MacOSUpdateConnectivity -Verbose -PerformBlueCoatLookup
# 3. filter results:
# $connectivity | Format-List -Property Blocked,TestUrl,UnblockUrl,DnsAliases,IpAddresses,Description,Resolved,ActualStatusCode,ExpectedStatusCode,UnexpectedStatus
# 4. save results:
# Save-HttpConnectivity -Objects $connectivity -FileName ('MacOSUpdateConnectivity_{0:yyyyMMdd_HHmmss}' -f (Get-Date))
Function Get-MacOSUpdateConnectivity() {
<#
.SYNOPSIS
Gets connectivity information for macOS updates.
.DESCRIPTION
Gets connectivity information for macOS updates.
.PARAMETER PerformBlueCoatLookup
Use Symantec BlueCoat SiteReview to lookup what SiteReview category the URL is in.
.EXAMPLE
Get-MacOSUpdateConnectivity
.EXAMPLE
Get-MacOSUpdateConnectivity -Verbose
.EXAMPLE
Get-MacOSUpdateConnectivity -PerformBlueCoatLookup
.EXAMPLE
Get-MacOSUpdateConnectivity -Verbose -PerformBlueCoatLookup
#>
[CmdletBinding()]
[OutputType([System.Collections.Generic.List[pscustomobject]])]
Param(
[Parameter(Mandatory=$false, HelpMessage='Whether to perform a BlueCoat Site Review lookup on the URL. Warning: The BlueCoat Site Review REST API is rate limited.')]
[switch]$PerformBluecoatLookup
)
$isVerbose = $VerbosePreference -eq 'Continue'
$data = New-Object System.Collections.Generic.List[System.Collections.Hashtable]
$data.Add(@{ TestUrl = 'https://swscan.apple.com'; ExpectedStatusCode = 403; PerformBluecoatLookup=$PerformBluecoatLookup; Verbose=$isVerbose })
$data.Add(@{ TestUrl = 'https://swcdnlocator.apple.com'; ExpectedStatusCode = 501; PerformBluecoatLookup=$PerformBluecoatLookup; Verbose=$isVerbose })
$data.Add(@{ TestUrl = 'https://swdownload.apple.com'; ExpectedStatusCode = 403; IgnoreCertificateValidationErrors=$true; PerformBluecoatLookup=$PerformBluecoatLookup; Verbose=$isVerbose })
$data.Add(@{ TestUrl = 'https://swcdn.apple.com'; ExpectedStatusCode = 404; IgnoreCertificateValidationErrors=$true; PerformBluecoatLookup=$PerformBluecoatLookup; Verbose=$isVerbose })
$data.Add(@{ TestUrl = 'https://swdist.apple.com'; ExpectedStatusCode = 403; PerformBluecoatLookup=$PerformBluecoatLookup; Verbose=$isVerbose })
$results = New-Object System.Collections.Generic.List[pscustomobject]
$data | ForEach-Object {
$connectivity = Get-HttpConnectivity @_
$results.Add($connectivity)
}
return $results
}