Done, ISS must be confed to handle ++ in filename!
parent
4b0165b7e7
commit
a248215c64
|
@ -40,17 +40,20 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath) {
|
||||||
$DeletedMods = 0
|
$DeletedMods = 0
|
||||||
# 0 is the parent HTTP Directory
|
# 0 is the parent HTTP Directory
|
||||||
$index = 1
|
$index = 1
|
||||||
|
$CleanLinks = $ModLinks -replace "/.*/",""
|
||||||
foreach ($Mod in $InternalModsNames) {
|
foreach ($Mod in $InternalModsNames) {
|
||||||
If ($ModLinks -notcontains "$Mod") {
|
If ($CleanLinks -notcontains "$Mod") {
|
||||||
Remove-Item $LocalMods\$Mod -Force -ErrorAction SilentlyContinue | Out-Null
|
Remove-Item $LocalMods\$Mod -Force -ErrorAction SilentlyContinue | Out-Null
|
||||||
$DeletedMods++
|
$DeletedMods++
|
||||||
}
|
}
|
||||||
$index++
|
$index++
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$CleanLinks = $ModLinks -replace "/.*/",""
|
||||||
|
|
||||||
#Loop through all links
|
#Loop through all links
|
||||||
$wc = New-Object System.Net.WebClient
|
$wc = New-Object System.Net.WebClient
|
||||||
$WebResponse.Links | Select-Object -ExpandProperty href | ForEach-Object {
|
$CleanLinks | ForEach-Object {
|
||||||
#Check for .ps1/.txt in listing/HREF:s in an index page pointing to .ps1/.txt
|
#Check for .ps1/.txt in listing/HREF:s in an index page pointing to .ps1/.txt
|
||||||
if (($_ -like "*.ps1") -or ($_ -like "*.txt")) {
|
if (($_ -like "*.ps1") -or ($_ -like "*.txt")) {
|
||||||
try {
|
try {
|
||||||
|
@ -81,38 +84,4 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath) {
|
||||||
}
|
}
|
||||||
return $ModsUpdated, $DeletedMods
|
return $ModsUpdated, $DeletedMods
|
||||||
}
|
}
|
||||||
# If path is UNC or local
|
|
||||||
else {
|
|
||||||
if ((Test-Path -Path $ExternalMods"\*.ps1") -or (Test-Path -Path $ExternalMods"\*.txt")) {
|
|
||||||
#Get File Names Externally
|
|
||||||
$ExternalModsNames = Get-ChildItem -Path $ExternalMods -Name -Recurse -Include *.ps1, *.txt
|
|
||||||
#Delete Local Mods that don't exist Externally
|
|
||||||
foreach ($Mod in $InternalModsNames){
|
|
||||||
If($Mod -notin $ExternalModsNames ){
|
|
||||||
Remove-Item $LocalMods\$Mod -Force -ErrorAction SilentlyContinue | Out-Null
|
|
||||||
$DeletedMods++
|
|
||||||
}
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
foreach ($Mod in $ExternalModsNames){
|
|
||||||
$dateExternalMod = ""
|
|
||||||
$dateLocalMod =""
|
|
||||||
if (Test-Path -Path $LocalMods"\"$Mod) {
|
|
||||||
$dateLocalMod = (Get-Item "$LocalMods\$Mod").LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss")
|
|
||||||
}
|
|
||||||
$dateExternalMod = (Get-Item "$ExternalMods\$Mod").LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss")
|
|
||||||
if ($dateExternalMod -gt $dateLocalMod) {
|
|
||||||
Copy-Item $ExternalMods\$Mod -Destination $LocalMods\$Mod -Force -ErrorAction SilentlyContinue | Out-Null
|
|
||||||
$ModsUpdated++
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
return $False
|
|
||||||
}
|
|
||||||
return $ModsUpdated, $DeletedMods
|
|
||||||
}
|
|
||||||
return $False
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue