我正在创建一个脚本,该脚本使用Powershell将Exchange Server 2013的远程升级从cu15升级到cu17。
它可以毫无问题地更新.Net Framework 4.6.2。
启动后会遇到错误。\ setup.exe / mode:upgrade / IAcceptExchangeServerLicenseTerms。
安装日志表明它无法验证凭据,但我不确定,它设法安装.net Framework没有问题。企业管理员(AD)中使用的帐户;组织管理(交流); &安培;本地服务器管理员(在所有交换服务器上)。
Exchange安装日志文件
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 ''.
正在使用的脚本
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 :(得分:0)
要检查安装了哪个.net Framework,您可以检查注册表(有关详细信息,请参阅here)。因此,您可以使用脚本检查注册表,以确保安装了正确的框架。
安装/更新.net后,您需要重新启动Exchange服务器(请参阅here),否则服务器/安装程序仍会检测到过时的Framework,安装将失败。另外一旦重新启动,.net Framework Optimization Service就会启动,我已经看到,当它运行时,Exchange升级将失败,因为Exchange仍然发现错误的.Net Framework版本。要在安装并重新启动后加快.net Framework优化服务,请检查here。