2017-10-04 14 views
0

Je suis en train de créer un script qui préforme une mise à niveau à distance d'un Exchange Server 2013 de cu15 vers cu17 en utilisant Powershell.Powershell Script Mise à niveau de CU 17 à distance Exchange Server 2013

Il met à jour .Net Framework 4.6.2 sans problème.

Il rencontre des erreurs après le démarrage. \ Setup.exe/mode: upgrade/IAcceptExchangeServerLicenseTerms.

Les journaux d'installation indiquent qu'il ne peut pas vérifier les informations d'identification, mais je ne suis pas sûr que, il parvient à installer .net Framework sans problème. Le compte utilisé dans un administrateur d'entreprise (AD); Admin de l'organisation (Exchange); & un administrateur de serveur local (sur tous les serveurs Exchange).

installation d'Exchange fichier journal

10/04/2017 09:06:27.0628] [0] ********************************************** 
[10/04/2017 09:06:28.0503] [0] Starting Microsoft Exchange Server 2013 Setup 
[10/04/2017 09:06:28.0503] [0] ********************************************** 
[10/04/2017 09:06:28.0518] [0] Local time zone: (UTC+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna. 
[10/04/2017 09:06:28.0518] [0] Operating system version: Microsoft Windows NT 6.2.9200.0. 
[10/04/2017 09:06:28.0518] [0] Setup version: 15.0.1320.4. 
[10/04/2017 09:06:28.0518] [0] Logged on user: Dev\exadmin. 
[10/04/2017 09:06:30.0003] [0] Command Line Parameter Name='mode', Value='Upgrade'. 
[10/04/2017 09:06:30.0003] [0] Command Line Parameter Name='iacceptexchangeserverlicenseterms', Value=''. 
[10/04/2017 09:06:30.0003] [0] Command Line Parameter Name='sourcedir', Value='c:\temp\Exchange2013-x64-cu17'. 
[10/04/2017 09:06:30.0081] [0] RuntimeAssembly was started with the following command: '***/mode:upgrade /IAcceptExchangeServerLicenseTerms*** /sourcedir:c:\temp\Exchange2013-x64-cu17'. 
[10/04/2017 09:06:30.0081] [0] The registry key, HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Exchange\v8.0, wasn't found. 
[10/04/2017 09:06:30.0081] [0] The registry key, HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ExchangeServer\v14, wasn't found. 
[10/04/2017 09:06:30.0081] [0] Copying Files... 
[10/04/2017 09:06:30.0081] [0] Starting copy from c:\temp\Exchange2013-x64-cu17\Setup\ServerRoles\Common to C:\Windows\Temp\ExchangeSetup. 
[10/04/2017 09:08:48.0113] [0] Finished copy from c:\temp\Exchange2013-x64-cu17\Setup\ServerRoles\Common to C:\Windows\Temp\ExchangeSetup. 
[10/04/2017 09:08:48.0113] [0] File copy complete. Setup will now collect additional information needed for installation. 
[10/04/2017 09:08:48.0129] [0] Assembly dll file location is C:\Windows\Temp\ExchangeSetup\Microsoft.Exchange.Setup.Console.dll 
[10/04/2017 09:08:53.0832] [0] Setup is choosing the domain controller to use 
[10/04/2017 09:09:00.0067] [0] Setup is choosing a local domain controller... 
[10/04/2017 09:09:00.0473] [0] Setup encountered a problem while validating the state of Active Directory: Active Directory operation failed on . The supplied credential for 'Dev\exadmin' is invalid. See the Exchange setup log for more information on this error. 
[10/04/2017 09:09:00.0473] [0] Active Directory operation failed on . The supplied credential for 'Dev\exadmin' is invalid. 
[10/04/2017 09:09:00.0473] [0] The supplied credential is invalid. 
[10/04/2017 09:09:00.0473] [0] Setup will use the domain controller ''. 
[10/04/2017 09:09:00.0473] [0] Setup will use the global catalog ''. 

Script utilisé

enter code here 
Add-PSSnapin Microsoft.Exchange* 
Import-Module FailoverClusters 
Set-ExecutionPolicy Unrestricted -Confirm:$false 

$Path = Get-Location 
$Path = $Path.ToString() 
$Date = Get-Date -Format "yyyy-MM-dd-hh-mm-ss" 
$FileNameFormat = "\" + (Get-Date -Format "yyyy-MM-dd-hh-mm-ss") + "-CU17-Upgrade.log" 
$Log = $Path + $FilenameFormat 
$Log = $Log.ToString() 

Start-Transcript -Path $Log -NoClobber -IncludeInvocationHeader 

#Exchange Servers 
$CUReady = $False 
$domain = (Get-WmiObject Win32_ComputerSystem).Domain 

$Location = $env:computername 
$Location = $Location.ToString() 
$Location = $Location.SubString(0,2) 
$Location 

$DAGs = Get-DatabaseAvailabilityGroup $Location* 
$DAGmenu = @{} 
$EXServermenu = @{} 

for ($i=1;$i -le $DAGs.count; $i++) { 
    Write-Host "$i. $($DAGs[$i-1].name)" 
    $DAGmenu.Add($i,($DAGs[$i-1].name)) 
    } 

[int]$Dans = Read-Host 'Choose DAG' 
$DAGselection = $DAGmenu.Item($Dans) 

$DAGName = Get-DatabaseAvailabilityGroup -identity $DAGselection | Select -exp Name 
$DAGName = $DAGName.ToString() 
#Write-Host -Fore Green $DAGName 

$servers = Get-DatabaseAvailabilityGroup -identity $DAGName -status | Select -exp Servers 
$servers = $servers.name 
[System.Collections.ArrayList]$exchangeServers = $servers 

for ($i=1;$i -le $exchangeServers.count; $i++) { 
    Write-Host "$i. $($exchangeServers[$i-1])" 
    $EXServermenu.Add($i,($exchangeServers[$i-1])) 
    } 

[int]$Eans = Read-Host 'Choose DAG' 
$EXSrvselection = $EXServermenu.Item($Eans) 

Write-Host -Fore Green $DAGName 
Write-Host -Fore White $EXSrvselection 

$exserver = $EXSrvselection 

IF (Test-Connection -ComputerName $exserver -Quiet) { 
write-host -Fore Green "Success! Test connection to $exserver" 
} ELSE { 
write-host -Fore Red "Failed! Test connection to $exserver failed. Please confirm connection and retry upgrade 
Script will exit - Line 41" 
exit 
} 

#$s = New-Pssession -Computername $exserver 
           Invoke-Command -ComputerName $exserver -ScriptBlock { 

           $exserver = [STRING] $exserver 

           If ($env:COMPUTERNAME -ne $($args[0])){ 

           write-host -Fore Green "Failed! Invoke Command to $($args[0]) could not be established. Please confirm connectivity and retry upgrade 
           Script will exit - Line 52" 
           Exit 
           } ELSE { 

           $Path = Get-Location 
           $Path = $Path.ToString() 

           Set-ExecutionPolicy Unrestricted -Force 
           Function Get-dotNetVersion { 

           $dotNetHashTable = New-Object HashTable 
           $dotNetHashTable.Add("4.5",378389) 
           $dotNetHashTable.Add("4.5.1",378675..378758) 
           $dotNetHashTable.Add("4.5.2",379893) 
           $dotNetHashTable.Add("4.6",393295..393297) 
           $dotNetHashTable.Add("4.6.1",394254..394271) 
           $dotNetHashTable.Add("4.6.2",394802..394806) 
           $dotNetHashTable.Add("4.7",460798) 

               $dotNetHashTable = $dotNetHashTable.GetEnumerator() | Sort-Object -Property Value 
               return $dotNetHashTable 

           } 

           $Server = $exserver 
           $reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey("LocalMachine",$($args[0])) 
           $keyname = 'SOFTWARE\\Microsoft\NET Framework Setup\NDP\v4\Full' 
           $key = $reg.OpenSubkey($keyname) 
           $value = $key.GetValue('Release') 
           $dotNetFramework = $value 

           #$dotNetFramework 
           $GetDotNetVersion = (Get-dotNetVersion | Where {$_.value -eq $dotNetFramework}) | Select -exp Name 

           IF ($GetDotNetVersion -ne "4.6.2") { 

     Write-host -ForegroundColor Yellow ".net version on server $($args[0]) is $GetDotNetVersion" 

               #$dotNetFramework462 = $Path + "\dotNetFramework4.6.2\NDP462-KB3151800-x86-x64-AllOS-ENU.exe" 
               $dotNetFramework462 = "c:\temp\Exchange2013-x64-cu17\'dotNetFramework4.6.2'\NDP462-KB3151800-x86-x64-AllOS-ENU.exe" 

       IF (Test-Path $dotNetFramework462){ 
                       write-host "Installing .NET 4.6..." -ForegroundColor Green 


                       #$dotargs = "/quiet /norestart" 
                       #$InstalldotNet = (Start-Process $dotNetFramework462 -ArgumentList $dotargs -Wait -PassThru).ExitCode 

                           IF ($InstalldotNet -eq 0) { 
          write-host -Fore Green "Successfully installed .NET 4.6" 

                           } ELSEIF ($InstalldotNet -ne 0) { write-host -Fore Red "Failed! 
                            Script will exit, Please review/install .NetFramework 4.6.2, then upgrade" 
                            Exit 
         } 

                       } ELSE { 

                           write-host -Fore Red "Failed! Script will exit, Please locate/install .NetFramework 4.6.2, then upgrade" 
                           Exit 

                    } 

               } ELSEIF ($GetDotNetVersion -eq "4.6.2") { 

      Write-host -ForegroundColor Green ".net version on server $($args[0]) is $GetDotNetVersion" 

                   $reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey("LocalMachine",$($args[0])) 
                   $keyname = 'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{4934D1EA-BE46-48B1-8847-F1AF20E892C1}' 
                   $key = $reg.OpenSubkey($keyname) 
                   $value = $key.GetValue('DisplayVersion') 
                   $ExVersion = $value 

                   IF ($ExVersion -eq '15.0.1263.5') { 
                       Write-host "Upgrading Exchange Server 2013 - $($args[0]) to CU17..." -ForegroundColor Green 

                       #$excu17 = $Path + "\setup.exe" 
                       $excu17 = "c:\temp\Exchange2013-x64-cu17\setup.exe" 

          IF (Test-Path $excu17){ 
                                                                                                $exargs = "/mode:upgrade /IAcceptExchangeServerLicenseTerms" 
                            $Installexcu17 = (Start-Process $excu17 -ArgumentList $exargs -Wait -PassThru).ExitCode 

                            IF ($Installexcu17 -eq 0) { 

          write-host -Fore Green "Successfully upgraded Exchange Server 2013 - $($args[0]) to CU17..." 

          } ELSEIF ($Installexcu17 -ne 0) { 

          write-host -Fore Red "Failed!to upgraded Exchange Server 2013 - $($args[0]) to CU17... 
          Script will exit. Please review exchange upgrade logs then upgrade" 
                            Exit 

          } 

                           } ELSE { 

                           write-host -Fore Red "Failed! 
                           Script will exit, Please locate exchange install files on Exchange Server 2013 - $($args[0]); review errors" 
                           Exit 
                           } 

                       } ELSE { 

                       write-host -Fore Red "Failed! 
                       Script will exit, Exchange server version on server - $($args[0]) is not CU15" 
                       Exit 
                   }        
               } 
       } 
} -ArgumentList $exserver 
Stop-Transcript -ErrorAction Ignore 
+0

Si vous utilisez les paramètres suivants, il semble que cela fonctionne, en transmettant les informations d'identification entrées, vous êtes invité à entrer un mot de passe. Qu'est-ce que l'ouverture d'utiliser les informations d'identification d'ouverture de session en cours et en ignorant l'entrée le mot de passe? $ s = Nouveau-PSSession -Computername "Server1" -Authentification CredSSP -red domaine \ utilisateur -verbose – Maverick

Répondre

0
  1. Pour vérifier que NET Framework est installé, vous pouvez vérifier le registre (voir here pour plus info). Vous pouvez donc vérifier le registre avec votre script pour vous assurer que le framework correct a été installé. Après .net est installé/mis à jour vous devez redémarrer votre serveur Exchange (voir here) sinon le serveur/installation détectera toujours un cadre obsolète et l'installation échouera. Une fois redémarré, le .net Framework Optimization Service est démarré et j'ai vu que lors de son exécution, une mise à niveau d'Exchange échouait car Exchange découvrait toujours une mauvaise version .Net Framework. Pour accélérer le service .net Framework Optimization après l'installation et redémarrez, vérifiez here.