From 43d531d51f59752c552b3ad4135f459723abc799 Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Sun, 18 Sep 2022 20:25:14 +0200 Subject: [PATCH] Prepared UNC/Local --- Winget-AutoUpdate-Install.ps1 | 6 +++ Winget-AutoUpdate/functions/Test-ListPath.ps1 | 46 ++++++++++++++++++- 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/Winget-AutoUpdate-Install.ps1 b/Winget-AutoUpdate-Install.ps1 index 9c27ece..3bd5daa 100644 --- a/Winget-AutoUpdate-Install.ps1 +++ b/Winget-AutoUpdate-Install.ps1 @@ -193,6 +193,12 @@ function Install-WingetAutoUpdate { } } Copy-Item -Path "$PSScriptRoot\Winget-AutoUpdate\*" -Destination $WingetUpdatePath -Recurse -Force -ErrorAction SilentlyContinue + + #White List or Black List source not Local if differs + if ($WingetUpdatePath -ne $ListPath){ + Test-ListPath $ListPath $UseWhiteList + } + #White List or Black List apps if ($UseWhiteList) { diff --git a/Winget-AutoUpdate/functions/Test-ListPath.ps1 b/Winget-AutoUpdate/functions/Test-ListPath.ps1 index dde6b28..e4e831e 100644 --- a/Winget-AutoUpdate/functions/Test-ListPath.ps1 +++ b/Winget-AutoUpdate/functions/Test-ListPath.ps1 @@ -1,6 +1,50 @@ #Function to check Black/White List Path function Test-ListPath ($ListPath, $UseWhiteList) { - + # UNC or Local Path + if ($UseWhiteList){ + $ListType="included" + } + else { + $ListType="excluded" + } + $Path = $ListPath + $PathInfo=[System.Uri]$Path + $ListPath = -join($Path, "\", "$ListType", "_apps.txt") + if($PathInfo.IsUnc){ + $PathType="UNC Path" + if(Test-Path -Path $ListPath -PathType leaf){ + Write-Output "Given path $Path type is $PathType and $ListPath is available..." + } + else { + Write-Output "Given path $Path type is $PathType and $ListPath is not available..." + } + } + elseif ($ListPath -like "http"){ + $wc = New-Object System.Net.WebClient + try { + $wc.OpenRead('http://www.domain.com/test.csv') | Out-Null + Write-Output 'File Exists' + } catch { + Write-Output 'Error / Not Found' + } + } + else { + $PathType="Local Path" + if(Test-Path -Path $ListPath -PathType leaf){ + Write-Output "Given path $Path type is $PathType and $ListPath is available..." + } + else { + Write-Output "Given path $Path type is $PathType and $ListPath is not available..." + } + } } + +$WingetUpdatePath = "$env:ProgramData\Winget-AutoUpdate" +$ListPath = "D:\Temp" +$UseWhiteList = $true +#White List or Black List in share/online if differs +if ($WingetUpdatePath -ne $ListPath){ + Test-ListPath $ListPath $UseWhiteList +}