Finalized Install

pull/166/head
KnifMelti 2022-09-20 03:08:06 +02:00
parent ed18c2bd13
commit 077dee73dc
1 changed files with 29 additions and 26 deletions

View File

@ -16,62 +16,65 @@ function Test-ListPath ($ListPath, $UseWhiteList) {
$PathInfo=[System.Uri]$ListPath $PathInfo=[System.Uri]$ListPath
if($PathInfo.IsUnc){ if($PathInfo.IsUnc){
$PathType="UNC Path"
if(Test-Path -Path $ExternalList -PathType leaf){ if(Test-Path -Path $ExternalList -PathType leaf){
Write-Host "Given path $ListPath type is $PathType and $ExternalList is available..."
$dateExternal = (Get-Item "$ExternalList").LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss") $dateExternal = (Get-Item "$ExternalList").LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss")
if ($dateExternal -gt $dateLocal) { if ($dateExternal -gt $dateLocal) {
Write-Host("$ExternalList is newer than $LocalList") try {
Copy-Item $ExternalList -Destination $LocalList -Force
}
catch {
return $False
}
return $true return $true
} }
} }
else {
Write-Host "Given path $ListPath type is $PathType and $ExternalList is not available..."
}
} }
elseif ($ListPath -like "http*"){ elseif ($ListPath -like "http*"){
$PathType="Web Path"
$ExternalList = -join($ListPath, "/", $ListType, "_apps.txt") $ExternalList = -join($ListPath, "/", $ListType, "_apps.txt")
$wc = New-Object System.Net.WebClient $wc = New-Object System.Net.WebClient
try { try {
$wc.OpenRead("$ExternalList").Close() | Out-Null $wc.OpenRead("$ExternalList").Close() | Out-Null
Write-Host "Given path $ListPath type is $PathType and $ExternalList is available..."
$dateExternal = ([DateTime]$wc.ResponseHeaders['Last-Modified']).ToString("yyyy-MM-dd HH:mm:ss") $dateExternal = ([DateTime]$wc.ResponseHeaders['Last-Modified']).ToString("yyyy-MM-dd HH:mm:ss")
if ($dateExternal -gt $dateLocal) { if ($dateExternal -gt $dateLocal) {
Write-Host("$ExternalList is newer than $LocalList") try {
$wc.DownloadFile($ExternalList, $LocalList)
}
catch {
return $False
}
return $true return $true
} }
} }
catch { catch {
Write-Host "Given path $ListPath type is $PathType and $ExternalList is not available..." return $False
} }
} }
else { else {
$PathType="Local Path"
if(Test-Path -Path $ExternalList -PathType leaf){ if(Test-Path -Path $ExternalList -PathType leaf){
Write-Host "Given path $ListPath type is $PathType and $ExternalList is available..."
$dateExternal = (Get-Item "$ExternalList").LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss") $dateExternal = (Get-Item "$ExternalList").LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss")
if ($dateExternal -gt $dateLocal) { if ($dateExternal -gt $dateLocal) {
Write-Host("$ExternalList is newer than $LocalList") try {
Copy-Item $ExternalList -Destination $LocalList -Force
}
catch {
return $False
}
return $true return $true
} }
} }
else {
Write-Host "Given path $ListPath type is $PathType and $ExternalList is not available..."
}
} }
return $false return $false
} }
$WingetUpdatePath = "$env:ProgramData\Winget-AutoUpdate" # $WingetUpdatePath = "$env:ProgramData\Winget-AutoUpdate"
$ListPath = "https://www.knifmelti.se" # $ListPath = "https://www.knifmelti.se"
#$ListPath = "D:\Temp" # #$ListPath = "D:\Temp"
#$ListPath = "\\TempSERVER" # #$ListPath = "\\TempSERVER"
#$UseWhiteList = $true # #$UseWhiteList = $true
#White List or Black List in share/online if differs # #White List or Black List in share/online if differs
if ($WingetUpdatePath -ne $ListPath){ # if ($WingetUpdatePath -ne $ListPath){
$NoClean = Test-ListPath $ListPath $UseWhiteList # $NoClean = Test-ListPath $ListPath $UseWhiteList
} # }
Write-Host $NoClean # Write-Host $NoClean