Error handling
parent
991dd55c2f
commit
3262d11099
|
@ -16,11 +16,17 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath) {
|
|||
# enable TLS 1.2 and TLS 1.1 protocols
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12, [Net.SecurityProtocolType]::Tls11
|
||||
#Get Index of $ExternalMods (or index page with href listings of all the Mods)
|
||||
try {
|
||||
$WebResponse = Invoke-WebRequest -Uri $ExternalMods
|
||||
# Get the list of links, skip the first one ("../") if listing is allowed
|
||||
$ModLinks = $WebResponse.Links | Select-Object -ExpandProperty href -Skip 1
|
||||
}
|
||||
catch {
|
||||
return $False
|
||||
}
|
||||
|
||||
#Delete Local Mods that doesn't exist Externally
|
||||
if ($WebResponse) {
|
||||
# Get the list of links, skip the first one ("../") if listing is allowed
|
||||
$ModLinks = $WebResponse.Links | Select-Object -ExpandProperty href -Skip 1
|
||||
foreach ($Mod in $InternalModsNames) {
|
||||
try {
|
||||
If ($Mod -notin $ModLinks) {
|
||||
|
@ -31,6 +37,7 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath) {
|
|||
#Do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#Loop through all links
|
||||
$WebResponse.Links | Select-Object -ExpandProperty href -Skip 1 | ForEach-Object {
|
||||
|
|
Loading…
Reference in New Issue