Compare done, actions now...
parent
817f61adab
commit
895222c784
|
@ -9,7 +9,6 @@ function Test-ListPath ($ListPath, $UseWhiteList) {
|
||||||
$ListType="excluded"
|
$ListType="excluded"
|
||||||
}
|
}
|
||||||
$LocalList = -join($WingetUpdatePath, "\", $ListType, "_apps.txt")
|
$LocalList = -join($WingetUpdatePath, "\", $ListType, "_apps.txt")
|
||||||
$ExternalList = $ListPath
|
|
||||||
$PathInfo=[System.Uri]$ListPath
|
$PathInfo=[System.Uri]$ListPath
|
||||||
|
|
||||||
if($PathInfo.IsUnc){
|
if($PathInfo.IsUnc){
|
||||||
|
@ -17,11 +16,10 @@ function Test-ListPath ($ListPath, $UseWhiteList) {
|
||||||
$ExternalList = -join($ListPath, "\", $ListType, "_apps.txt")
|
$ExternalList = -join($ListPath, "\", $ListType, "_apps.txt")
|
||||||
if(Test-Path -Path $ExternalList -PathType leaf){
|
if(Test-Path -Path $ExternalList -PathType leaf){
|
||||||
Write-Output "Given path $ListPath type is $PathType and $ExternalList is available..."
|
Write-Output "Given path $ListPath type is $PathType and $ExternalList is available..."
|
||||||
|
|
||||||
$dateLocal = (Get-Item "$LocalList").LastWriteTime
|
$dateLocal = (Get-Item "$LocalList").LastWriteTime
|
||||||
$dateExternal = (Get-Item "$ListPath").LastWriteTime
|
$dateExternal = (Get-Item "$ListPath").LastWriteTime
|
||||||
if ($dateExternal -gt $dateLocal) {
|
if ($dateExternal -gt $dateLocal) {
|
||||||
Write-Host("$ExternalList was modified after $LocalList")
|
Write-Host("$ExternalList is newer than $LocalList")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -33,8 +31,13 @@ function Test-ListPath ($ListPath, $UseWhiteList) {
|
||||||
$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") | Out-Null
|
$wc.OpenRead("$ExternalList").Close() | Out-Null
|
||||||
Write-Output "Given path $ListPath type is $PathType and $ExternalList is available..."
|
Write-Output "Given path $ListPath type is $PathType and $ExternalList is available..."
|
||||||
|
$dateLocal = (Get-Item "$LocalList").LastWriteTime
|
||||||
|
$dateExternal = $wc.ResponseHeaders['Last-Modified']
|
||||||
|
if ($dateExternal -gt $dateLocal) {
|
||||||
|
Write-Host("$ExternalList is newer than $LocalList")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
Write-Output "Given path $ListPath type is $PathType and $ExternalList is not available..."
|
Write-Output "Given path $ListPath type is $PathType and $ExternalList is not available..."
|
||||||
|
@ -45,11 +48,10 @@ function Test-ListPath ($ListPath, $UseWhiteList) {
|
||||||
$ExternalList = -join($ListPath, "\", $ListType, "_apps.txt")
|
$ExternalList = -join($ListPath, "\", $ListType, "_apps.txt")
|
||||||
if(Test-Path -Path $ExternalList -PathType leaf){
|
if(Test-Path -Path $ExternalList -PathType leaf){
|
||||||
Write-Output "Given path $ListPath type is $PathType and $ExternalList is available..."
|
Write-Output "Given path $ListPath type is $PathType and $ExternalList is available..."
|
||||||
|
|
||||||
$dateLocal = (Get-Item "$LocalList").LastWriteTime
|
$dateLocal = (Get-Item "$LocalList").LastWriteTime
|
||||||
$dateExternal = (Get-Item "$ListPath").LastWriteTime
|
$dateExternal = (Get-Item "$ListPath").LastWriteTime
|
||||||
if ($dateExternal -gt $dateLocal) {
|
if ($dateExternal -gt $dateLocal) {
|
||||||
Write-Host("$ExternalList was modified after $LocalList")
|
Write-Host("$ExternalList is newer than $LocalList")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -59,8 +61,8 @@ function Test-ListPath ($ListPath, $UseWhiteList) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$WingetUpdatePath = "$env:ProgramData\Winget-AutoUpdate"
|
$WingetUpdatePath = "$env:ProgramData\Winget-AutoUpdate"
|
||||||
$ListPath = "D:\Temp"
|
$ListPath = "https://www.knifmelti.se"
|
||||||
$UseWhiteList = $false
|
#$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){
|
||||||
Test-ListPath $ListPath $UseWhiteList
|
Test-ListPath $ListPath $UseWhiteList
|
||||||
|
|
Loading…
Reference in New Issue