" was run: "System.ArgumentOutOfRangeException: StartIndex cannot be less than zero.

Kannan Balakrishnan 1 Reputation point
2022-01-30T08:47:38.473+00:00

I get an error given below while running Active Directory Preparation with the command

Setup.exe /PrepareAD /IAcceptExchangeServerLicenseTerms_DiagnosticDataON

I have no supportive document available with Microsoft for this error.

The same error occurs when I try to upgrade Exchange server 2016 Cu 20 to CU 22.

Error:
The following error was generated when "$error.Clear();
$createTenantRoot = ($RoleIsDatacenter -or $RoleIsPartnerHosted);
$createMsoSyncRoot = $RoleIsDatacenter;

      #$RoleDatacenterIsManagementForest is set only in Datacenter deployment; interpret its absense as $false
      [bool]$isManagementForest = ($RoleDatacenterIsManagementForest -eq $true);

      if ($RolePrepareAllDomains)
      {
          initialize-DomainPermissions -AllDomains:$true -CreateTenantRoot:$createTenantRoot -CreateMsoSyncRoot:$createMsoSyncRoot -IsManagementForest:$isManagementForest;
      }
      elseif ($RoleDomain -ne $null)
      {
          initialize-DomainPermissions -Domain $RoleDomain -CreateTenantRoot:$createTenantRoot -CreateMsoSyncRoot:$createMsoSyncRoot -IsManagementForest:$isManagementForest;
      }
      else
      {
          initialize-DomainPermissions -CreateTenantRoot:$createTenantRoot -CreateMsoSyncRoot:$createMsoSyncRoot -IsManagementForest:$isManagementForest;
      }
    " was run: "System.ArgumentOutOfRangeException: StartIndex cannot be less than zero.

Parameter name: startIndex
at System.String.Remove(Int32 startIndex, Int32 count)
at Microsoft.Exchange.Management.Tasks.DirectoryCommon.IsRODCType(String DnsHostName)
at Microsoft.Exchange.Management.Tasks.InitializeDomainPermissions.InternalProcessRecord()
at Microsoft.Exchange.Configuration.Tasks.Task.<ProcessRecord>b__91_1()
at Microsoft.Exchange.Configuration.Tasks.Task.InvokeRetryableFunc(String funcName, Action func, Boolean terminatePipelineIfFailed)
at Microsoft.Exchange.Configuration.Tasks.Task.ProcessTaskStage(TaskStage taskStage, Action initFunc, Action mainFunc, Action completeFunc)
at Microsoft.Exchange.Configuration.Tasks.Task.ProcessRecord()
at System.Management.Automation.CommandProcessor.ProcessRecord()".

Exchange Exchange Server Management
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Aaron Xue-MSFT 2,596 Reputation points Microsoft External Staff
    2022-01-31T02:54:10.457+00:00

    Hi @Kannan Balakrishnan ,

    The issue may occur with the container in AD is missing.

    Did you install the IIS RUL Rewrite module and Universal C Runtime in Windows (KB 2999226)?

    Cumulative Update 22 for Exchange Server 2016 (KB5005333) (microsoft.com)

    And you need to run below command before you install the CU22.

    E:\Setup.exe /IAcceptExchangeServerLicenseTerms /PrepareSchema  
    E:\Setup.exe /IAcceptExchangeServerLicenseTerms /PrepareAD /OrganizationName:"MYDomain"  
    E:\Setup.exe /IAcceptExchangeServerLicenseTerms /PrepareAllDomains  
    

    Exchange Server prerequisites, Exchange 2019 system requirements, Exchange 2019 requirements | Microsoft Learn

    I find a similar case for you referenfce.

    Unable to Install CU21 for Exchange 2016 - Microsoft Q&A


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.