Prepared Web Path

pull/166/head
KnifMelti 2022-09-18 20:40:22 +02:00
parent 43d531d51f
commit c928b7aa93
1 changed files with 16 additions and 12 deletions

View File

@ -10,9 +10,10 @@ function Test-ListPath ($ListPath, $UseWhiteList) {
} }
$Path = $ListPath $Path = $ListPath
$PathInfo=[System.Uri]$Path $PathInfo=[System.Uri]$Path
$ListPath = -join($Path, "\", "$ListType", "_apps.txt")
if($PathInfo.IsUnc){ if($PathInfo.IsUnc){
$PathType="UNC Path" $PathType="UNC Path"
$ListPath = -join($Path, "\", "$ListType", "_apps.txt")
if(Test-Path -Path $ListPath -PathType leaf){ if(Test-Path -Path $ListPath -PathType leaf){
Write-Output "Given path $Path type is $PathType and $ListPath is available..." Write-Output "Given path $Path type is $PathType and $ListPath is available..."
} }
@ -20,17 +21,20 @@ function Test-ListPath ($ListPath, $UseWhiteList) {
Write-Output "Given path $Path type is $PathType and $ListPath is not available..." Write-Output "Given path $Path type is $PathType and $ListPath is not available..."
} }
} }
elseif ($ListPath -like "http"){ elseif ($ListPath -like "http*"){
$PathType="Web Path"
$ListPath = -join($Path, "/", "$ListType", "_apps.txt")
$wc = New-Object System.Net.WebClient $wc = New-Object System.Net.WebClient
try { try {
$wc.OpenRead('http://www.domain.com/test.csv') | Out-Null $wc.OpenRead("$ListPath") | Out-Null
Write-Output 'File Exists' Write-Output "Given path $Path type is $PathType and $ListPath is available..."
} catch { } catch {
Write-Output 'Error / Not Found' Write-Output "Given path $Path type is $PathType and $ListPath is not available..."
} }
} }
else { else {
$PathType="Local Path" $PathType="Local Path"
$ListPath = -join($Path, "\", "$ListType", "_apps.txt")
if(Test-Path -Path $ListPath -PathType leaf){ if(Test-Path -Path $ListPath -PathType leaf){
Write-Output "Given path $Path type is $PathType and $ListPath is available..." Write-Output "Given path $Path type is $PathType and $ListPath is available..."
} }
@ -41,10 +45,10 @@ function Test-ListPath ($ListPath, $UseWhiteList) {
} }
$WingetUpdatePath = "$env:ProgramData\Winget-AutoUpdate" # $WingetUpdatePath = "$env:ProgramData\Winget-AutoUpdate"
$ListPath = "D:\Temp" # $ListPath = "https://www.knifmelti.se"
$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){
Test-ListPath $ListPath $UseWhiteList # Test-ListPath $ListPath $UseWhiteList
} # }