Domain join is failed due to network unavailability during TS execution

Hello friends,

Domain join is the most important step in the Task Sequence. If the domain join does not happen, there is no value to execute the task sequence ahead. Because if we missed joining the domain during the task sequence execution, the domain users can not log in to the machine and we have to reimage the machine again, simply this waste of time.

Here is one important thing we have to note down, this step is not failing anyhow. So, if the domain join is failed even. Still, a task sequence will execute the next step.

We only know that domain join is failed while login in the machine post-task sequence completes.

Why is domain join fail sometimes?

We are joining the machines to the domain once driver installation is done (before first reboot the machine). We observed post drivers’ installation sometimes network drivers loos the connectivity and this is causing the domain join failure.

Why not wait for the network to be stable and pause the domain step till the time.

Yes, we can do it via a script, we can wait for the network until and unless we cannot reach the domain controller.

Let's create a Powershell script and add it before "Apply Network Settings".


<#

    .SYNOPSIS

    Domain join is failed due to network unavailability during TS execution.

    .DESCRIPTION

    A Technician may connect the loose LAN cable to the target device and that leads to failing the Network connectivity break during the TS Execution.

    This script will help to ensure the LAN cable is connected properly during the TS execution.

    .NOTES

    =============================================================================================================================================

    Created with:     Windows PowerShell ISE

    Created on:       Tuesday, August 17, 2021 2:05:44 PM

    Created by:       Dashrath Chate

    Organization:     MYCompanyName

    =============================================================================================================================================

#>

    $TSEnv = New-Object -ComObject 'Microsoft.SMS.TSEnvironment'

    $DPvalue = $TSEnv.Value("_SMSTSLastContentDownloadLocation")

    $startIndex = $DPValue.IndexOf('://') + 3

    $endIndex = $DPValue.IndexOf('/', $startIndex)

    $DPName = $DPvalue.Substring($startIndex, $endIndex-$startIndex)

    $TSEnv.Value('DPName') = $DPName

    $ping = Test-Connection  -ComputerName $DPName -Quiet

    $logFile = 'C:\_SMSTaskSequence\Logs\smstslog\dc_PingResponse.log'

    $ping = Test-Connection  -ComputerName $DPName -Count 1 -Quiet

if (!(Test-Connection  -ComputerName $DPName -Count 1 -Quiet))

    {

        do {

        [System.Windows.MessageBox]::Show('Unable to connect to the local DP please check network connectivity and try again later.','Network Connectivity Issue','OK','Error')

          $date = Get-Date

           Write-Output "New Logs started" ,$date  | Out-File -Append $logFile

            Write-Output "Unable to connect to the local DP please check network connectivity and try again later." | Out-File -Append $logFile

            $date = Get-Date

            Ping $DPName | Out-File -Append $logFile -ErrorAction SilentlyContinue

            Write-Output "End of Result" | Out-File -Append $logFile

            }

        until ($ping -contains "True")

   }

else

    {

    $date = Get-Date

    Write-Output "New Logs started" ,$date  | Out-File -Append $logFile

    Write-Output "machine is online and able to connect to the local DP"| Out-File -Append $logFile

    Test-Connection -ComputerName $DPName -Count 3| Out-File -Append $logFile -ErrorAction SilentlyContinue

    Write-Output "End of Result" | Out-File -Append $logFile

    }

No comments:

Post a Comment

Leave your valuable words here for improve better.