Como atualizar PowerShell 5 para 7 no Windows 11

Como atualizar o PowerShell para a versão mais recente

Como atualizar o PowerShell para a versão mais recente

Muitas pessoas ainda usam o PowerShell antigo que vem instalado no Windows, mas existe uma versão mais nova, mais rápida e muito mais segura.

Neste guia você vai aprender como atualizar o PowerShell de forma automática, silenciosa e segura usando apenas ferramentas oficiais.


Por que atualizar o PowerShell?

  • Mais rápido
  • Mais seguro
  • Compatível com scripts modernos
  • Atualizações frequentes
  • Melhor desempenho
  • Suporte oficial atual

O Windows ainda usa o PowerShell 5 por padrão, mas a Microsoft recomenda usar o PowerShell 7 ou superior.


Antes de começar

  1. Abra o menu iniciar
  2. Digite PowerShell
  3. Clique com botão direito
  4. Executar como administrador

Script 1 — Instalar ou atualizar PowerShell automaticamente


winget install --id Microsoft.PowerShell `
--source winget `
--exact `
--silent `
--force `
--accept-package-agreements `
--accept-source-agreements

winget upgrade --id Microsoft.PowerShell `
--silent `
--force `
--accept-package-agreements `
--accept-source-agreements


$pwshPath = "$env:ProgramFiles\PowerShell\7"

$currentPath = [Environment]::GetEnvironmentVariable("Path","Machine")

if ($currentPath -notlike "*$pwshPath*") {
    [Environment]::SetEnvironmentVariable(
        "Path",
        "$pwshPath;$currentPath",
        "Machine"
    )
}


$profilePath = $PROFILE.AllUsersAllHosts

if (!(Test-Path $profilePath)) {
    New-Item -ItemType File -Path $profilePath -Force
}

Add-Content $profilePath "`nSet-Alias powershell pwsh"

Depois de executar, reinicie o computador.


Script 2 — Tornar o novo PowerShell o padrão


New-Item -Path $PROFILE.AllUsersAllHosts -ItemType File -Force
Add-Content $PROFILE.AllUsersAllHosts 'Set-Alias powershell pwsh'


Diferença entre PowerShell 5 e PowerShell 7

  • PowerShell 7 é mais rápido
  • Tem suporte moderno
  • Recebe atualizações
  • Mais compatível com Windows 11
  • Melhor para scripts
  • Mais seguro

Dicas importantes

  • Sempre execute como administrador
  • Reinicie após instalar
  • Não apague o PowerShell antigo manualmente
  • Use apenas comandos oficiais

Conclusão

Atualizar o PowerShell é um processo simples e melhora muito o desempenho, segurança e compatibilidade do sistema.

Usando os scripts deste artigo você consegue atualizar de forma automática, silenciosa e segura.

Se você trabalha com scripts, automação ou TI, manter o PowerShell atualizado é essencial.