Skip to content

Instantly share code, notes, and snippets.

@asmirbe
Created June 1, 2022 21:53
Show Gist options
  • Save asmirbe/9b713071f66e5d72438d7cf1e81064bb to your computer and use it in GitHub Desktop.
Save asmirbe/9b713071f66e5d72438d7cf1e81064bb to your computer and use it in GitHub Desktop.
Same as before but with Powershell
$r = Invoke-WebRequest -Uri 'https://gitcdn.link/cdn/asmirbelkic/b064933ad55335bfde34db9de3ede0d1/raw/fe4160a246757f266d212f52051528431df6867d/list.xml' -Method:Get -ContentType 'application/xml' -ErrorAction:Stop -TimeoutSec 60
$bn = ($r.Content)
$file = '$PSScriptRoot/list.xml'
if (-not(Test-Path -Path $file -PathType Leaf)) {
try {
$null = New-Item -Path $file -Force -ErrorAction Stop
Set-Content $file $bn
Write-Host 'The list [$file] has been created.'
}
catch {
throw $_.Exception.Message
}
}
else {
Remove-Item -Path $file -Force -ErrorAction Stop
try {
$null = New-Item -Path $file -Force -ErrorAction Stop
Set-Content $file $bn
Write-Host 'The list [$file] has been replaced.'
}
catch {
throw $_.Exception.Message
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment