I have a small problem with a powershell script ... I'm learning how to program and I do not know how to solve it.
$descargas = "C:/Maqueta"
if(Test-Path -Path $descargas -PathType Container){
Write-Host "El directorio $descargas ya esxiste" -ForegroundColor Yellow
}else{
Write-Host "Creando directorio $descargas" -ForegroundColor Green
New-Item -Path $descargas -ItemType directory
}
#Descargar
$lista = ("googlechromestandaloneenterprise64.msi","Winrar.exe")
$Uri =("https://dl.google.com/tag/s/appguid%3D%7B8A69D345-D564-463C-AFF1-A69D9E530F96%7D%26iid%3D%7B03FE9563-80F9-119F-DA3D-72FBBB94BC26%7D%26lang%3Den%26browser%3D4%26usagestats%3D0%26appname%3DGoogle%2520Chrome%26needsadmin%3Dprefers%26ap%3Dx64-stable/dl/chrome/install/googlechromestandaloneenterprise64.msi",
"https://www.winrar.es/descargas/103")
$destino = "$descargas"
#Error en los bucles
Foreach($var in $lista){
Foreach($var2 in $Uri){
Invoke-WebRequest $var2 -OutFile $destino\$var
}
}
At the time of downloading the indicated packages Google-Chrome and Winrar duplicates me the packages to the same in this case winrar. The download weight in the beginning is the correct one according to the google chrome package but for some reason winrar is downloaded again and overwrites the package.
This is an example of the problem.
And this is the same case, the packages are downloaded as different but they are the same.
Given my little experience in this world that is almost null I do not know what to do ...