Download temp file in temp folder

This commit is contained in:
Isaac Shoebottom 2023-10-26 11:15:34 -03:00
parent 07f3f8981b
commit 96daf4f5ae
2 changed files with 14 additions and 6 deletions

View File

@ -6,11 +6,15 @@ If (Test-Path -Path ".\ToggleUpdates.ps1" -PathType Leaf) {
.\ToggleUpdates.ps1 $appId
}
Else {
# construct temp path
$env:temp = [System.IO.Path]::GetTempPath()
$tempPath = $env:temp + "\ToggleUpdates.ps1"
# Download the network script
$wc = New-Object System.Net.WebClient
$wc.DownloadFile($networkLocation, ".\ToggleUpdates.ps1")
$wc.DownloadFile($networkLocation, $tempPath)
# Invoke the network script
.\ToggleUpdates.ps1 $appId
&$tempPath $appId
# Delete the network script
Remove-Item -Path ".\ToggleUpdates.ps1"
Remove-Item -Path $tempPath
}

View File

@ -6,11 +6,15 @@ If (Test-Path -Path ".\ToggleUpdates.ps1" -PathType Leaf) {
.\ToggleUpdates.ps1 $appId
}
Else {
# construct temp path
$env:temp = [System.IO.Path]::GetTempPath()
$tempPath = $env:temp + "\ToggleUpdates.ps1"
# Download the network script
$wc = New-Object System.Net.WebClient
$wc.DownloadFile($networkLocation, ".\ToggleUpdates.ps1")
$wc.DownloadFile($networkLocation, $tempPath)
# Invoke the network script
.\ToggleUpdates.ps1 $appId
&$tempPath $appId
# Delete the network script
Remove-Item -Path ".\ToggleUpdates.ps1"
Remove-Item -Path $tempPath
}