#requires -Version 5.1 $ErrorActionPreference = 'Stop' [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 $UrlPrincipal = 'https://get.goit.com.br/scripts/GOIT-Setup-Center.ps1' $HashEsperado = 'F79B0B60413C54A5DD4ACC9E416C293FC082DA21C137C565B121D4FE01F3B6F5' $PastaTemporaria = Join-Path $env:TEMP 'GOIT-SetupCenter' $ArquivoPrincipal = Join-Path $PastaTemporaria 'GOIT-Setup-Center.ps1' try { Write-Host '' Write-Host 'GOIT Setup Center - carregando...' if (-not (Test-Path -LiteralPath $PastaTemporaria -PathType Container)) { New-Item -ItemType Directory -Path $PastaTemporaria -Force | Out-Null } Invoke-WebRequest -Uri $UrlPrincipal -OutFile $ArquivoPrincipal -UseBasicParsing if (-not (Test-Path -LiteralPath $ArquivoPrincipal -PathType Leaf)) { throw 'O script principal nao foi baixado.' } $HashAtual = (Get-FileHash -LiteralPath $ArquivoPrincipal -Algorithm SHA256).Hash.ToUpperInvariant() if ($HashAtual -ne $HashEsperado) { throw "Falha de integridade. Esperado: $HashEsperado | Encontrado: $HashAtual" } $PowerShellExe = Join-Path $env:SystemRoot 'System32\WindowsPowerShell\v1.0\powershell.exe' $Argumentos = '-NoProfile -ExecutionPolicy Bypass -File "{0}"' -f $ArquivoPrincipal $Processo = Start-Process ` -FilePath $PowerShellExe ` -Verb RunAs ` -ArgumentList $Argumentos ` -Wait ` -PassThru if ($Processo.ExitCode -ne 0) { throw "O GOIT Setup Center terminou com o codigo $($Processo.ExitCode)." } } catch { Write-Host '' Write-Host 'ERRO:' -ForegroundColor Red Write-Host $_.Exception.Message -ForegroundColor Red Write-Host '' [void](Read-Host 'Pressione ENTER para encerrar') } finally { Remove-Item -LiteralPath $ArquivoPrincipal -Force -ErrorAction SilentlyContinue }