List-/ModsPath rewritten, now validated on Apache

pull/257/head
KnifMelti 2023-01-04 00:46:24 +01:00
parent feaaa6566a
commit d7039653b8
2 changed files with 19 additions and 9 deletions

View File

@ -91,6 +91,7 @@ Get Black/White List from Path (URL/UNC/Local) (download/copy to Winget-AutoUpda
**-ModsPath**
Get Mods from Path (URL/UNC/Local) (download/copy to `mods` in Winget-AutoUpdate installation location if external mods are newer).
For URL: This requires a site directory with `Options +Indexes` in `.htaccess` and no index page overriding the listing of files.
Validated on IIS/Apache.
Or an index page with href listing of all the Mods to be downloaded:
```
<ul>
@ -165,6 +166,8 @@ In an enterprise environment it's crucial that different groups can have differe
**WAU** doesn't have any setting that can be changed except for when installing (or editing the registry/the task `Winget-AutoUpdate` as **Admin**).
With the use of **ADML/ADMX** files you can manage every **WAU** setting from within **GPO**.
They will be detected/evaluated during the next run of **WAU** (taking effect before any actions).
The **GPO ADMX/ADML** validated with:
[Windows 10 - Validate ADMX for Ingestion](https://developer.vmware.com/samples/7115/windows-10---validate-admx-for-ingestion)
Read more in the `README.md` under the directory **Policies**
![image](https://user-images.githubusercontent.com/102996177/210157417-60e84023-088e-4299-9d76-b34bb0c5f088.png)

View File

@ -11,8 +11,6 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath) {
# If path is URL
if ($ExternalMods -like "http*") {
$wc = New-Object System.Net.WebClient
# 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 listing of all the Mods)
@ -24,25 +22,34 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath) {
}
# Collect the external list of href links
$ModLinks = $WebResponse.Links | Select-Object -ExpandProperty href
$ModLinks = $WebResponse.Links | Select-Object -ExpandProperty HREF
#If there's a directory path in the HREF:s, delete it (IIS)
$ModLinks -replace "/.*/", ""
#$ModLinks -add <a href='"' + $ModLinks + "\">"" + $$ModLinks + "</a>"
$CleanLinks = $ModLinks -replace "/.*/",""
#<a href="Microsoft.PowerToys-installed.ps1"> Microsoft.PowerToys-installed.ps1</a>
#<A HREF="/wau/mods/Microsoft.PowerToys-installed.ps1">Microsoft.PowerToys-installed.ps1</A>
#(\x3Ca\x20href=\x22)(.*|.*)
#Modify strings to HREF:s
$index = 0
foreach ($Mod in $CleanLinks) {
if ($Mod) {
$CleanLinks[$index] = '<a href="' + $Mod + '"> ' + $Mod + '</a>'
}
$index++
}
#Delete Local Mods that don't exist Externally
$DeletedMods = 0
# 0 is the parent HTTP Directory
$index = 1
foreach ($Mod in $InternalModsNames) {
If ($Mod -notin $ModLinks) {
If ($ModLinks -notcontains "$Mod") {
Remove-Item $LocalMods\$Mod -Force -ErrorAction SilentlyContinue | Out-Null
$DeletedMods++
}
$index++
}
#Loop through all links
$wc = New-Object System.Net.WebClient
$WebResponse.Links | Select-Object -ExpandProperty href | ForEach-Object {
#Check for .ps1/.txt in listing/HREF:s in an index page pointing to .ps1/.txt
if (($_ -like "*.ps1") -or ($_ -like "*.txt")) {