{"id":847208,"date":"2026-07-29T15:37:01","date_gmt":"2026-07-29T15:37:01","guid":{"rendered":"https:\/\/www.ninjaone.com\/?post_type=script_hub&#038;p=847208"},"modified":"2026-07-29T15:37:01","modified_gmt":"2026-07-29T15:37:01","slug":"atualizacao-do-powershell-para-a-versao-5-1","status":"publish","type":"script_hub","link":"https:\/\/www.ninjaone.com\/pt-br\/script-hub\/atualizacao-do-powershell-para-a-versao-5-1\/","title":{"rendered":"Um guia completo: Como atualizar o PowerShell para a vers\u00e3o 5.1"},"content":{"rendered":"<h2>Principais conclus\u00f5es<\/h2>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"1\" data-aria-level=\"1\">de atualiza\u00e7\u00e3o automatizada do PowerShell: O script automatiza a atualiza\u00e7\u00e3o do PowerShell para a vers\u00e3o 5.1 em vers\u00f5es espec\u00edficas do Windows.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"2\" data-aria-level=\"1\"><strong>Efici\u00eancia para profissionais de TI<\/strong>: Ideal para MSPs e profissionais de TI que gerenciam v\u00e1rios sistemas, garantindo uniformidade e economizando tempo.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"3\" data-aria-level=\"1\"><strong>Verifica\u00e7\u00f5es de compatibilidade<\/strong>: Verifica automaticamente a compatibilidade do sistema e impede a execu\u00e7\u00e3o em sistemas que tenham o Exchange Server instalado.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"4\" data-aria-level=\"1\"><strong>Tratamento robusto de erros<\/strong>: Inclui tratamento de erros e registro em log para atualiza\u00e7\u00f5es confi\u00e1veis e rastre\u00e1veis.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"5\" data-aria-level=\"1\"><strong>Gerenciamento de pr\u00e9-requisitos<\/strong>: Identifica e instala os pr\u00e9-requisitos necess\u00e1rios, como atualiza\u00e7\u00f5es do .NET Framework, antes de atualizar o PowerShell.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"6\" data-aria-level=\"1\">personaliz\u00e1vel e escal\u00e1vel: Pode ser adaptado a ambientes espec\u00edficos e \u00e9 escal\u00e1vel para v\u00e1rios sistemas.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"7\" data-aria-level=\"1\"><strong>Medidas de seguran\u00e7a<\/strong>: Recomenda que os testes sejam realizados em ambientes controlados e que sejam feitos backups antes da implanta\u00e7\u00e3o.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"8\" data-aria-level=\"1\"><strong>Equipado com ferramentas de gerenciamento<\/strong>: Utilize em conjunto com ferramentas como o NinjaOne para um gerenciamento e monitoramento abrangentes do sistema.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"9\" data-aria-level=\"1\"><strong>Atualiza\u00e7\u00e3o por script x atualiza\u00e7\u00e3o manual<\/strong>: Oferece um processo de atualiza\u00e7\u00e3o mais confi\u00e1vel e eficiente em compara\u00e7\u00e3o com os m\u00e9todos manuais tradicionais.<\/li>\n<\/ul>\n<h2>Contexto<\/h2>\n<p>O PowerShell \u00e9 uma ferramenta essencial nos ambientes modernos de TI, oferecendo uma plataforma vers\u00e1til para automatizar tarefas e gerenciar sistemas. Manter o PowerShell atualizado \u00e9 essencial para a seguran\u00e7a, a compatibilidade e o acesso a novos recursos. Esta postagem do blog aborda um script do PowerShell desenvolvido especificamente para atualizar o PowerShell para a vers\u00e3o 5.1, uma tarefa relevante para muitos profissionais de TI e para os Provedores de Servi\u00e7os Gerenciados (MSPs) d <a href=\"https:\/\/www.ninjaone.com\/what-is-an-msp\/\">.\u00a0<\/a><\/p>\n<p>O script em quest\u00e3o automatiza a atualiza\u00e7\u00e3o do PowerShell para a vers\u00e3o 5.1 nos sistemas operacionais <a href=\"https:\/\/www.ninjaone.com\/pt-br\/blog\/windows-server-2012-end-of-life-o-que-saber\/\">, Windows Server 2012,<\/a> R2 e Windows 8.1. \u00c9 uma vantagem significativa, pois as atualiza\u00e7\u00f5es manuais podem ser demoradas e propensas a erros. Para profissionais de TI e MSPs que gerenciam v\u00e1rios sistemas, um script como esse garante consist\u00eancia e efici\u00eancia na manuten\u00e7\u00e3o de sua infraestrutura.<\/p>\n<h2>O roteiro:<\/h2>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\">#Requires -Version 2\r\n\r\n&lt;#\r\n.SYNOPSIS\r\n    Upgrades PowerShell to version 5.1.\r\n.DESCRIPTION\r\n    NOTICE - Multiple reboots may be required to continue with the install in the case\r\n    where 3.0 is installed.\r\n    This requires the user to log back in manually after the reboot before continuing.\r\n\r\n    The script will upgrade powershell to 5.1 on the following OS'\r\n        Windows Server 2012 R2\r\n        Windows 8.1\r\n\r\n    This script WILL NOT run if Exchange Server is installed!\r\n\r\n    A log of this process is created in $env:Temp\\upgrade_powershell.log\r\n    This log can used to see how the script faired after an automatic reboot.\r\n.EXAMPLE\r\n    -Restart\r\nPARAMETER: -Restart\r\n    Restart even if a restart isn't required.\r\n\r\n.EXAMPLE\r\n    # upgrade to 5.1 with defaults and manual login and reboots\r\n    (No Parameters)\r\n\r\n.OUTPUTS\r\n    None\r\n.NOTES\r\n    Minium Supported OS: Windows 8.1, Server 2012 R2\r\n    Release Notes: Renamed script and added Script Variable support\r\nBy using this script, you indicate your acceptance of the following legal terms as well as our Terms of Use at https:\/\/www.ninjaone.com\/terms-of-use.\r\n    Ownership Rights: NinjaOne owns and will continue to own all right, title, and interest in and to the script (including the copyright). NinjaOne is giving you a limited license to use the script in accordance with these legal terms. \r\n    Use Limitation: You may only use the script for your legitimate personal or internal business purposes, and you may not share the script with another party. \r\n    Republication Prohibition: Under no circumstances are you permitted to re-publish the script in any script library or website belonging to or under the control of any other software provider. \r\n    Warranty Disclaimer: The script is provided \u201cas is\u201d and \u201cas available\u201d, without warranty of any kind. NinjaOne makes no promise or guarantee that the script will be free from defects or that it will meet your specific needs or expectations. \r\n    Assumption of Risk: Your use of the script is at your own risk. You acknowledge that there are certain inherent risks in using the script, and you understand and assume each of those risks. \r\n    Waiver and Release: You will not hold NinjaOne responsible for any adverse or unintended consequences resulting from your use of the script, and you waive any legal or equitable rights or remedies you may have against NinjaOne relating to your use of the script. \r\n    EULA: If you are a NinjaOne customer, your use of the script is subject to the End User License Agreement applicable to you (EULA).\r\n#&gt;\r\n\r\n[CmdletBinding()]\r\nParam(\r\n    [string]$Version = \"5.1\",\r\n    [switch]$ForceRestart = [System.Convert]::ToBoolean($env:ForceRestart)\r\n)\r\n\r\nbegin {\r\n\r\n    # Modified version from: https:\/\/github.com\/jborean93\/ansible-windows\/tree\/master\/scripts\r\n    #\r\n    # LICENSE: https:\/\/github.com\/jborean93\/ansible-windows\/blob\/master\/LICENSE\r\n    # MIT License\r\n    #\r\n    # Copyright (c) 2017 Jordan Borean\r\n    #\r\n    # Permission is hereby granted, free of charge, to any person obtaining a copy\r\n    # of this software and associated documentation files (the \"Software\"), to deal\r\n    # in the Software without restriction, including without limitation the rights\r\n    # to use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\r\n    # copies of the Software, and to permit persons to whom the Software is\r\n    # furnished to do so, subject to the following conditions:\r\n    #\r\n    # The above copyright notice and this permission notice shall be included in all\r\n    # copies or substantial portions of the Software.\r\n    #\r\n    # THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n    # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n    # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n    # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n    # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n    # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\n    # SOFTWARE.\r\n\r\n\r\n    $ErrorActionPreference = 'Stop'\r\n    if ([System.Management.Automation.ActionPreference]::SilentlyContinue -ne $VerbosePreference) {\r\n        $VerbosePreference = \"Continue\"\r\n    }\r\n\r\n    if ([System.Convert]::ToBoolean($env:Verbose)) {\r\n        $Verbose = $true\r\n    }\r\n\r\n    # Don't upgrade PowerShell if Exchange is installed, this needs manual intervention to not cause problems.\r\n    if ($(Get-Service -Name MSExchangeServiceHost -ErrorAction SilentlyContinue) -or $(Get-Command Exsetup.exe -ErrorAction SilentlyContinue | ForEach-Object { $_.FileVersionInfo })) {\r\n        Write-Host \"Exchange looks to be installed. Aborting PowerShell upgrade.\"\r\n        exit 1\r\n    }\r\n\r\n    [System.Net.ServicePointManager]::ServerCertificateValidationCallback = { $true }\r\n\r\n    $tmp_dir = $env:temp\r\n    if (-not (Test-Path -Path $tmp_dir)) {\r\n        New-Item -Path $tmp_dir -ItemType Directory &gt; $null\r\n    }\r\n\r\n    Function Write-Log($message, $level = \"INFO\") {\r\n        # Poor man's implementation of Log4Net\r\n        $date_stamp = Get-Date -Format s\r\n        $log_entry = \"$date_stamp - $level - $message\"\r\n        $log_file = \"$tmp_dir\\upgrade_powershell.log\"\r\n        Write-Host -Message $log_entry\r\n        Add-Content -Path $log_file -Value $log_entry\r\n    }\r\n\r\n    Function Invoke-Reboot {\r\n\r\n        Write-Log -message \"need to reboot server to continue powershell upgrade\"\r\n\r\n        shutdown.exe \/r \/t 30\r\n    }\r\n\r\n    Function Invoke-RunProcess($executable, $arguments) {\r\n        $process = New-Object -TypeName System.Diagnostics.Process\r\n        $psi = $process.StartInfo\r\n        $psi.FileName = $executable\r\n        $psi.Arguments = $arguments\r\n        Write-Log -message \"starting new process '$executable $arguments'\"\r\n        $process.Start() | Out-Null\r\n    \r\n        $process.WaitForExit() | Out-Null\r\n        $exit_code = $process.ExitCode\r\n        Write-Log -message \"process completed with exit code '$exit_code'\"\r\n\r\n        return $exit_code\r\n    }\r\n\r\n    Function Invoke-DownloadFile($url, $path) {\r\n        Write-Log -message \"downloading url '$url' to '$path'\"\r\n        $client = New-Object -TypeName System.Net.WebClient\r\n        $client.DownloadFile($url, $path)\r\n    }\r\n\r\n    Write-Log -message \"starting script\"\r\n    # on PS v1.0, upgrade to 2.0 and then run the script again\r\n    if ($PSVersionTable -eq $null) {\r\n        Write-Log -message \"upgrading powershell v1.0 to v2.0\"\r\n        $architecture = $env:PROCESSOR_ARCHITECTURE\r\n        if ($architecture -eq \"AMD64\") {\r\n            $url = \"https:\/\/download.microsoft.com\/download\/2\/8\/6\/28686477-3242-4E96-9009-30B16BED89AF\/Windows6.0-KB968930-x64.msu\"\r\n        }\r\n        else {\r\n            $url = \"https:\/\/download.microsoft.com\/download\/F\/9\/E\/F9EF6ACB-2BA8-4845-9C10-85FC4A69B207\/Windows6.0-KB968930-x86.msu\"\r\n        }\r\n        $filename = $url.Split(\"\/\")[-1]\r\n        $file = \"$tmp_dir\\$filename\"\r\n        Invoke-DownloadFile -url $url -path $file\r\n        $exit_code = Invoke-RunProcess -executable $file -arguments \"\/quiet \/norestart\"\r\n        if ($exit_code -ne 0 -and $exit_code -ne 3010) {\r\n            $error_msg = \"failed to update Powershell from 1.0 to 2.0: exit code $exit_code\"\r\n            Write-Log -message $error_msg -level \"ERROR\"\r\n            throw $error_msg\r\n        }\r\n        Invoke-Reboot\r\n    }\r\n\r\n    # exit if the target version is the same as the actual version\r\n    $current_ps_version = [version]\"$($PSVersionTable.PSVersion.Major).$($PSVersionTable.PSVersion.Minor)\"\r\n    if ($current_ps_version -eq [version]$Version) {\r\n        Write-Log -message \"current and target PS version are the same, no action is required\"\r\n        exit 0\r\n    }\r\n\r\n    $os_version = [Version](Get-Item -Path \"$env:SystemRoot\\System32\\kernel32.dll\").VersionInfo.ProductVersion\r\n    $architecture = $env:PROCESSOR_ARCHITECTURE\r\n    if ($architecture -eq \"AMD64\") {\r\n        $architecture = \"x64\"\r\n    }\r\n    else {\r\n        $architecture = \"x86\"\r\n    }\r\n}\r\n\r\nprocess {\r\n    $actions = @()\r\n    switch ($Version) {\r\n        \"5.1\" {\r\n            if ($os_version -lt [version]\"6.3\") {\r\n                $error_msg = \"cannot upgrade Server 2008 to Powershell v5.1, v3 is the latest supported\"\r\n                Write-Log -message $error_msg -level \"ERROR\"\r\n                throw $error_msg\r\n            }\r\n            # check if WMF 3 is installed, need to be uninstalled before 5.1\r\n            if ($os_version.Minor -lt 2) {\r\n                $wmf3_installed = Get-HotFix -Id \"KB2506143\" -ErrorAction SilentlyContinue\r\n                if ($wmf3_installed) {\r\n                    $error_msg = \"cannot upgrade to Powershell v5.1, this needs manual intervention.\"\r\n                    Write-Log -message $error_msg -level \"ERROR\"\r\n                    throw $error_msg\r\n                }\r\n            }\r\n            $actions += \"5.1\"\r\n            break\r\n        }\r\n        default {\r\n            $error_msg = \"version '$Version' is not supported in this upgrade script\"\r\n            Write-Log -message $error_msg -level \"ERROR\"\r\n            throw $error_msg\r\n        }\r\n    }\r\n\r\n    # detect if .NET 4.5.2 is not installed and add to the actions\r\n    $dotnet_path = \"HKLM:\\SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\v4\\Full\"\r\n    if (-not $(Test-Path -Path $dotnet_path -ErrorAction SilentlyContinue)) {\r\n        $dotnet_upgrade_needed = $true\r\n    }\r\n    else {\r\n        $dotnet_version = Get-ItemProperty -Path $dotnet_path -Name Release -ErrorAction SilentlyContinue\r\n        if ($dotnet_version) {\r\n            # 379893 == 4.5.2\r\n            if ($dotnet_version.Release -lt 379893) {\r\n                $dotnet_upgrade_needed = $true\r\n            }        \r\n        }\r\n        else {\r\n            $dotnet_upgrade_needed = $true\r\n        }\r\n    }\r\n    if ($dotnet_upgrade_needed) {\r\n        $actions = @(\"dotnet\") + $actions\r\n    }\r\n\r\n    Write-Log -message \"The following actions will be performed: $($actions -join \", \")\"\r\n    foreach ($action in $actions) {\r\n        $url = $null\r\n        $file = $null\r\n        $arguments = \"\/quiet \/norestart\"\r\n\r\n        switch ($action) {\r\n            \"dotnet\" {\r\n                Write-Log -message \"running .NET update to 4.5.2\"\r\n                $url = \"https:\/\/download.microsoft.com\/download\/E\/2\/1\/E21644B5-2DF2-47C2-91BD-63C560427900\/NDP452-KB2901907-x86-x64-AllOS-ENU.exe\"\r\n                $error_msg = \"failed to update .NET to 4.5.2\"\r\n                $arguments = \"\/q \/norestart\"\r\n                break\r\n            }\r\n            \"5.1\" {\r\n                Write-Log -message \"running powershell update to version 5.1\"\r\n                if ($os_version.Minor -eq 2) {\r\n                    # Server 2012\r\n                    $url = \"http:\/\/download.microsoft.com\/download\/6\/F\/5\/6F5FF66C-6775-42B0-86C4-47D41F2DA187\/W2K12-KB3191565-x64.msu\"\r\n                }\r\n                else {\r\n                    # Server 2012 R2 and Windows 8.1\r\n                    if ($architecture -eq \"x64\") {\r\n                        $url = \"http:\/\/download.microsoft.com\/download\/6\/F\/5\/6F5FF66C-6775-42B0-86C4-47D41F2DA187\/Win8.1AndW2K12R2-KB3191564-x64.msu\"\r\n                    }\r\n                    else {\r\n                        $url = \"http:\/\/download.microsoft.com\/download\/6\/F\/5\/6F5FF66C-6775-42B0-86C4-47D41F2DA187\/Win8.1-KB3191564-x86.msu\"\r\n                    }\r\n                }\r\n                break\r\n            }\r\n            default {\r\n                $error_msg = \"unknown action '$action'\"\r\n                Write-Log -message $error_msg -level \"ERROR\"\r\n            }\r\n        }\r\n\r\n        if ($null -eq $file) {\r\n            $filename = $url.Split(\"\/\")[-1]\r\n            $file = \"$tmp_dir\\$filename\"\r\n        }\r\n        if ($null -ne $url) {\r\n            Invoke-DownloadFile -url $url -path $file\r\n        }\r\n    \r\n        $exit_code = Invoke-RunProcess -executable $file -arguments $arguments\r\n        if ($exit_code -ne 0 -and $exit_code -ne 3010) {\r\n            $log_msg = \"$($error_msg): exit code $exit_code\"\r\n            Write-Log -message $log_msg -level \"ERROR\"\r\n            throw $log_msg\r\n        }\r\n        if ($exit_code -eq 3010) {\r\n            $log_msg = \"Reboot is required!\"\r\n            Write-Log -message $log_msg -level \"WARN\"\r\n            break\r\n        }\r\n    }\r\n    if ($ForceRestart) {\r\n        Invoke-Reboot\r\n    }\r\n}\r\nend {\r\n    \r\n    \r\n    \r\n}<\/pre>\n<p>&nbsp;<\/p>\n\n<div class=\"in-context-cta\"><p>Acesse mais de 300 scripts no NinjaOne Dojo<\/p>\n<p><a href=\"https:\/\/www.ninjaone.com\/freetrialform\/\">Obter acesso<\/a><\/p>\n<\/div>\n<h2>Discrimina\u00e7\u00e3o detalhada<\/h2>\n<p>O script funciona em v\u00e1rias etapas:<\/p>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"1\" data-aria-level=\"1\"><strong>Prepara\u00e7\u00e3o e verifica\u00e7\u00e3o<\/strong>: Primeiro, define as prefer\u00eancias de tratamento de erros e verifica se o Microsoft Exchange Server est\u00e1 instalado, j\u00e1 que a presen\u00e7a desse servidor exige uma abordagem diferente para a atualiza\u00e7\u00e3o.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"2\" data-aria-level=\"1\"><strong>Registro inicial<\/strong>: Em seguida, ele inicializa o registro de logs para acompanhar o andamento do script, o que \u00e9 especialmente \u00fatil em ambientes onde tarefas automatizadas s\u00e3o executadas com frequ\u00eancia.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"3\" data-aria-level=\"1\"><strong>Verifica\u00e7\u00e3o da vers\u00e3o do PowerShell<\/strong>: O script <a href=\"https:\/\/www.ninjaone.com\/blog\/how-to-do-a-powershell-version-check\/\">verifica a vers\u00e3o atual do PowerShell<\/a>. Se j\u00e1 for a vers\u00e3o 5.1, o script \u00e9 encerrado, pois n\u00e3o \u00e9 necess\u00e1ria nenhuma atualiza\u00e7\u00e3o.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"4\" data-aria-level=\"1\"><strong>Verifica\u00e7\u00e3o do sistema operacional e da arquitetura<\/strong>: Ele identifica o sistema operacional e a arquitetura (x64 ou x86) para determinar o pacote de atualiza\u00e7\u00e3o correto.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"5\" data-aria-level=\"1\"><strong>Determina\u00e7\u00e3o da a\u00e7\u00e3o<\/strong>: O script determina se deve atualizar o .NET Framework antes do PowerShell, um pr\u00e9-requisito para o PowerShell 5.1.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"6\" data-aria-level=\"1\"><strong>Baixando e instalando atualiza\u00e7\u00f5es<\/strong>: Em seguida, ele baixa e instala os pacotes necess\u00e1rios, cuidando das reinicializa\u00e7\u00f5es, se for o caso.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"7\" data-aria-level=\"1\"><strong>Op\u00e7\u00e3o de reinicializa\u00e7\u00e3o for\u00e7ada<\/strong>: Um par\u00e2metro permite uma reinicializa\u00e7\u00e3o for\u00e7ada, se necess\u00e1rio, garantindo que as atualiza\u00e7\u00f5es sejam aplicadas integralmente.<\/li>\n<\/ul>\n<p>Se voc\u00ea quiser verificar a vers\u00e3o do PowerShell, aqui est\u00e1 um guia em v\u00eddeo que mostra como fazer isso: <a class=\"\" href=\"https:\/\/www.ninjaone.com\/videos\/powershell\/how-to-do-a-powershell-version-check\/\" target=\"_new\" rel=\"noopener\" data-start=\"124\" data-end=\"240\">Como verificar a vers\u00e3o do PowerShell<\/a>.<\/p>\n<h2>Poss\u00edveis casos de uso<\/h2>\n<p>Considere um MSP respons\u00e1vel pela manuten\u00e7\u00e3o de v\u00e1rios ambientes de clientes. Eles poderiam implementar esse script em v\u00e1rios sistemas, garantindo que todos estejam atualizados para a mesma vers\u00e3o do PowerShell. Essa uniformidade simplifica o gerenciamento e reduz os problemas de compatibilidade.<\/p>\n<h2>Compara\u00e7\u00f5es<\/h2>\n<p>Tradicionalmente, as atualiza\u00e7\u00f5es do PowerShell podem ser realizadas manualmente ou por meio de um script em lote. Este script do PowerShell oferece uma abordagem mais sofisticada, com tratamento de erros, registro em log e verifica\u00e7\u00f5es de ambiente, reduzindo o risco de interrup\u00e7\u00e3o ou falha.<\/p>\n<h2>Implica\u00e7\u00f5es<\/h2>\n<p>O uso desse script pode melhorar significativamente a efici\u00eancia de TI d, mas requer uma an\u00e1lise cuidadosa. Uma atualiza\u00e7\u00e3o incorreta pode causar instabilidade no sistema. Sempre fa\u00e7a testes em um ambiente controlado antes da implanta\u00e7\u00e3o em larga escala.<\/p>\n<h2>Recomenda\u00e7\u00f5es<\/h2>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"1\" data-aria-level=\"1\"><strong>Teste primeiro<\/strong>: Sempre execute o script em um ambiente de teste antes de implement\u00e1-lo em grande escala.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"2\" data-aria-level=\"1\"><strong>Sistemas de backup<\/strong>: Certifique-se de que os backups do sistema estejam atualizados para o caso de ocorrer uma falha.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"3\" data-aria-level=\"1\"><strong>Personalize conforme necess\u00e1rio<\/strong>: Se necess\u00e1rio, modifique o script para ambientes espec\u00edficos.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"4\" data-aria-level=\"1\"><strong>Logs do monitor<\/strong>: Verifique regularmente os registros gerados para identificar poss\u00edveis problemas ou anomalias.<\/li>\n<\/ul>\n<h2>Considera\u00e7\u00f5es finais<\/h2>\n<p>No contexto de uma gest\u00e3o de TI simplificada, ferramentas como o NinjaOne podem complementar esses scripts, oferecendo um controle e monitoramen <a href=\"https:\/\/www.ninjaone.com\/pt-br\/\">es e centralizados.<\/a> Os recursos do NinjaOne para gerenciar atualiza\u00e7\u00f5es e monitorar a integridade do sistema podem funcionar em conjunto com esses scripts, aumentando a efici\u00eancia e a confiabilidade gerais da TI. A combina\u00e7\u00e3o da automa\u00e7\u00e3o do <a href=\"https:\/\/www.ninjaone.com\/script-hub\/\">por meio de scripts<\/a> e de uma ferramenta de gerenciamento robusta como o NinjaOne garante que os ambientes de TI n\u00e3o apenas sejam atualizados, mas tamb\u00e9m monitorados e gerenciados de forma consistente para atingir o m\u00e1ximo desempenho.<\/p>\n","protected":false},"author":35,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_acf_changed":false,"_relevanssi_hide_post":"","_relevanssi_hide_content":"","_relevanssi_pin_for_all":"","_relevanssi_pin_keywords":"","_relevanssi_unpin_keywords":"","_relevanssi_related_keywords":"","_relevanssi_related_include_ids":"","_relevanssi_related_exclude_ids":"","_relevanssi_related_no_append":"","_relevanssi_related_not_related":"","_relevanssi_related_posts":"","_relevanssi_noindex_reason":"","_lmt_disableupdate":"no","_lmt_disable":""},"operating_system":[4212],"use_cases":[12600],"class_list":["post-847208","script_hub","type-script_hub","status-publish","hentry","script_hub_category-windows"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/script_hub\/847208","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/script_hub"}],"about":[{"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/types\/script_hub"}],"author":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/users\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/comments?post=847208"}],"wp:attachment":[{"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/media?parent=847208"}],"wp:term":[{"taxonomy":"script_hub_category","embeddable":true,"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/operating_system?post=847208"},{"taxonomy":"use_cases","embeddable":true,"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/use_cases?post=847208"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}