{"id":216049,"date":"2024-03-18T07:59:16","date_gmt":"2024-03-18T07:59:16","guid":{"rendered":"https:\/\/www.ninjaone.com\/?post_type=script_hub&#038;p=216049"},"modified":"2024-03-18T07:59:16","modified_gmt":"2024-03-18T07:59:16","slug":"aggiornare-powershell-a-5-1","status":"publish","type":"script_hub","link":"https:\/\/www.ninjaone.com\/it\/script-hub\/aggiornare-powershell-a-5-1\/","title":{"rendered":"Una guida completa: Come aggiornare PowerShell alla versione 5.1"},"content":{"rendered":"<h2>Punti chiave<\/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>Aggiornare PowerShell automaticamente<\/strong>: Lo script automatizza l&#8217;aggiornamento di PowerShell alla versione 5.1 su versioni specifiche di 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>Efficienza per i professionisti IT<\/strong>: Ideale per MSP e professionisti IT che gestiscono pi\u00f9 sistemi, perch\u00e9 garantisce uniformit\u00e0 e risparmio di 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>Controlli di compatibilit\u00e0<\/strong>: Verifica automaticamente la compatibilit\u00e0 del sistema e impedisce l&#8217;esecuzione sui sistemi in cui \u00e8 installato Exchange Server.<\/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>Solida gestione degli errori<\/strong>: Lo script per aggiornare PowerShell include la gestione e il logging degli errori per aggiornamenti affidabili e tracciabili.<\/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>Gestione dei prerequisiti<\/strong>: Identifica e installa i prerequisiti necessari, come gli aggiornamenti di .NET Framework, prima di aggiornare 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\"><strong>Personalizzabile e scalabile<\/strong>: Lo script per aggiornare PowerShell pu\u00f2 essere modificato per ambienti specifici e scalabile su pi\u00f9 sistemi.<\/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>Misure di sicurezza<\/strong>: Si raccomanda di eseguire test in ambienti controllati e di assicurarsi di avere un backup disponibile prima della distribuzione dello script per aggiornare 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=\"8\" data-aria-level=\"1\"><strong>Potenziato con strumenti di gestione<\/strong>: Utilizza lo script per aggiornare PowerShell insieme a strumenti come NinjaOne per una gestione e un monitoraggio completi del 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>Aggiornamento manuale e tramite script<\/strong>: Offre un processo di aggiornamento pi\u00f9 affidabile ed efficiente rispetto ai metodi manuali tradizionali.<\/li>\n<\/ul>\n<h2>Background<\/h2>\n<p>PowerShell \u00e8 uno strumento fondamentale nei moderni ambienti IT, in quanto offre una piattaforma versatile per automatizzare le attivit\u00e0 e gestire i sistemi. Mantenere PowerShell aggiornato \u00e8 essenziale per la sicurezza, la compatibilit\u00e0 e l&#8217;accesso a nuove funzionalit\u00e0. In questo articolo analizzeremo uno script PowerShell specificamente progettato per aggiornare PowerShell alla versione 5.1, un&#8217;attivit\u00e0 rilevante per molti professionisti IT e <a href=\"https:\/\/www.ninjaone.com\/it\/cos-e-un-msp\/\">Managed Service Provider (MSP).\u00a0<\/a><\/p>\n<p>Lo script in questione permette di aggiornare PowerShell alla versione 5.1, automaticamente, su <a href=\"https:\/\/www.ninjaone.com\/it\/blog\/windows-server-2012-fine-del-ciclo-di-vita-cosa-sapere\/\">Windows Server 2012<\/a> R2 e Windows 8.1. Si tratta di un vantaggio significativo perch\u00e9 gli aggiornamenti manuali possono richiedere molto tempo e sono soggetti a errori. Per i professionisti IT e gli MSP che gestiscono pi\u00f9 sistemi, uno script di questo tipo garantisce coerenza ed efficienza nella manutenzione dell&#8217;infrastruttura.<\/p>\n<h2>Lo script per aggiornare PowerShell alla versione 5.1:<\/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\/it\/condizioni-utilizzo\/\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>Accedi a oltre 700 script nel Dojo NinjaOne<\/p>\n<p><a href=\"https:\/\/www.ninjaone.com\/it\/prova-gratuita\/\">Ottieni l&#8217;accesso<\/a><\/p>\n<\/div>\n<h2>Analisi dettagliata<\/h2>\n<p>Lo script per aggiornare PowerShell opera in diverse fasi:<\/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>Preparazione e verifica<\/strong>: Inizia impostando le preferenze di gestione degli errori e verificando la presenza di Microsoft Exchange Server, poich\u00e9 la sua presenza richiede un approccio di aggiornamento diverso.<\/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>Logging iniziale<\/strong>: Quindi inizializza il logging per seguire i progressi dello script, particolarmente utile in ambienti in cui le attivit\u00e0 automatiche vengono eseguite frequentemente.<\/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 della versione di PowerShell<\/strong>: Lo script per aggiornare PowerShell controlla la versione corrente di PowerShell. Se \u00e8 gi\u00e0 5.1, lo script esce perch\u00e9 non \u00e8 necessario alcun aggiornamento.<\/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>Controllo del sistema operativo e dell&#8217;architettura<\/strong>: Identifica il sistema operativo e l&#8217;architettura (x64 o x86) per determinare il pacchetto di aggiornamento corretto.<\/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>Determinazione dell&#8217;azione<\/strong>: Lo script decide se aggiornare <a href=\"https:\/\/www.ninjaone.com\/it\/script-hub\/installare-il-net-framework-4-con-powershell-2\/\">.NET Framework<\/a> prima di aggiornare PowerShell, un prerequisito per la versione 5.1 di 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\"><strong>Scaricare e installare gli aggiornamenti<\/strong>: Quindi scarica e installa i pacchetti necessari, gestendo i riavvii se necessario.<\/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>Opzione di riavvio forzato<\/strong>: Un parametro consente un riavvio forzato, se necessario, per garantire l&#8217;applicazione completa degli aggiornamenti.<\/li>\n<\/ul>\n<h2>Casi d&#8217;uso potenziali<\/h2>\n<p>Immagina un MSP responsabile della manutenzione di pi\u00f9 ambienti di clienti. Potrebbe distribuire questo script per aggiornare PowerShell su vari sistemi, assicurandosi che tutti siano aggiornati alla stessa versione di PowerShell. Questa uniformit\u00e0 semplifica la gestione e riduce i problemi di compatibilit\u00e0.<\/p>\n<h2>Confronti<\/h2>\n<p>Tradizionalmente, gli aggiornamenti di PowerShell possono essere eseguiti manualmente o tramite uno script batch. Questo script per aggiornare PowerShell offre un approccio pi\u00f9 sofisticato con gestione degli errori, registrazione e controlli ambientali, riducendo il rischio di interruzioni o guasti.<\/p>\n<h2>Domande frequenti<\/h2>\n<p><strong>D: Questo script per aggiornare PowerShell funziona su qualsiasi sistema operativo Windows?<\/strong><br \/>\nR: No, \u00e8 progettato per Windows Server 2012 R2 e Windows 8.1.<\/p>\n<p><strong>D: Cosa succede se \u00e8 installato Microsoft Exchange Server?<\/strong><br \/>\nR: Lo script non proceder\u00e0 con l&#8217;aggiornamento, poich\u00e9 Exchange Server richiede un processo di aggiornamento diverso.<\/p>\n<p><strong>D: Posso usare questo script per aggiornare PowerShell a versioni diverse dalla 5.1?<\/strong><br \/>\nR: Lo script \u00e8 progettato in modo specifico per aggiornare PowerShell alla versione 5.1. Per le altre versioni sarebbero necessarie delle modifiche.<\/p>\n<h2>Implicazioni<\/h2>\n<p>L&#8217;uso di questo script per aggiornare PowerShell pu\u00f2 migliorare notevolmente l&#8217;<a href=\"https:\/\/www.ninjaone.com\/it\/efficienza-it\/\"> efficienza IT<\/a>, ma richiede un approccio attento. Un aggiornamento non corretto pu\u00f2 causare l&#8217;instabilit\u00e0 del sistema. Esegui sempre dei test in un ambiente controllato prima di un&#8217;ampia diffusione.<\/p>\n<h2>Raccomandazioni<\/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>Prima di tutto, effettua dei test<\/strong>: Esegui sempre lo script per aggiornare PowerShell in un ambiente di prova prima di distribuirlo su larga scala.<\/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>Sistemi di backup<\/strong>: Assicurati che i backup del sistema siano aggiornati, per poterli usare in caso di guasto.<\/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>Personalizza secondo le necessit\u00e0<\/strong>: Se necessario, modifica lo script per aggiornare PowerShell in ambienti specifici.<\/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>Monitora i log<\/strong>: Controlla regolarmente i log generati per individuare eventuali problemi o anomalie.<\/li>\n<\/ul>\n<h2>Considerazioni finali<\/h2>\n<p>Nel contesto della gestione semplificata dell&#8217;IT, strumenti come NinjaOne possono integrare script come quello per aggiornare PowerShell offrendo un <a href=\"https:\/\/www.ninjaone.com\/it\/\">controllo e un monitoraggio centralizzati<\/a>. Le funzionalit\u00e0 di NinjaOne per la gestione degli aggiornamenti e il monitoraggio dell\u2019integrit\u00e0 del sistema possono lavorare insieme agli script, migliorando l&#8217;efficienza e l&#8217;affidabilit\u00e0 IT complessiva. La combinazione di <a href=\"https:\/\/www.ninjaone.com\/it\/script-hub\/\">automazione tramite script<\/a> e di un solido strumento di gestione come NinjaOne assicura che gli ambienti IT non solo siano aggiornati, ma anche costantemente monitorati e gestiti per ottenere le massime prestazioni.<\/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":[4276],"class_list":["post-216049","script_hub","type-script_hub","status-publish","hentry","script_hub_category-windows","use_cases-aggiorna-il-software"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.ninjaone.com\/it\/wp-json\/wp\/v2\/script_hub\/216049","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ninjaone.com\/it\/wp-json\/wp\/v2\/script_hub"}],"about":[{"href":"https:\/\/www.ninjaone.com\/it\/wp-json\/wp\/v2\/types\/script_hub"}],"author":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/it\/wp-json\/wp\/v2\/users\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/it\/wp-json\/wp\/v2\/comments?post=216049"}],"wp:attachment":[{"href":"https:\/\/www.ninjaone.com\/it\/wp-json\/wp\/v2\/media?parent=216049"}],"wp:term":[{"taxonomy":"script_hub_category","embeddable":true,"href":"https:\/\/www.ninjaone.com\/it\/wp-json\/wp\/v2\/operating_system?post=216049"},{"taxonomy":"use_cases","embeddable":true,"href":"https:\/\/www.ninjaone.com\/it\/wp-json\/wp\/v2\/use_cases?post=216049"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}