Script para solucionar errores 53 y 64 en el distmgr.log de un Servidor Secundario

Hay situaciones en las que un servidor secundario parece perder comunicación con uno de usos puntos de distribución de forma aleatoria.

Aunque se mantenga la conectividad con ping, a tengamos acceso a la unidad Admin$ con la cuenta local de sistema, en el log distmgr.log vemos constantes eventos como los siguientes solo con uno de los DPs.

Failed to make a network connection to \\Server\ADMIN$ (0x35).

Cannot establish connection to [“Display=\\Server\”]MSWNET:[“SMS_SITE=S01”]\\Server\. Error = 53

Copying D:\Foler\File to \\SERVER02\SMSPKGD$\FileFolder, Failed, Win32 Error = 64                SMS_DISTRIBUTION_MANAGER        date 7:53:25 AM      74756 (0x12404)

En mi entorno esto pasa con bastante frecuencia, y los pasos de diagnóstico y solución son siempre los mismos, por eso he creado un script con la solución de forma que se puede automatizar.

Por favor testeadlo antes de usarlo de forma extensiva, viene sin garantías y a mí me funciona, pero como reinicia el servicio smsexec puede tener impacto en producción.

Añadí algunos controles al script para que, ante las acciones con más impacto, pregunte antes de realizarlas, si se elimina esta parte, y se integra con una herramienta de monitorización, puede hacer tu vida como administrado de CofigMgr mucho más llevadera.

Aquí están las líneas, sòlo copia y pega en PowerShell (o el ISE) y a disfrutarlo:

#Script to repair the DPs connection events 53 and 64 on secondary site

#On ConfigMgr

#Created on 20 Oct 2016

#Created By Raul del Moral

#**************************************

# Version 2.0 adding the next features:

# Enable control on the script execution so ask for the restart on SmsExec service

# Enable logging on the server with the whole process

# Enable control on SmsExec service so if not detected stops

#**************************************

#Set the variables to use on the script

$DPName =  Read-Host -Prompt ‘Enter the DP name’

if (!$DPName ) {Write-host -ForegroundColor Red -backgroundColor White “Please provide a DP name”

exit(1)}

$Admin = “$DPName\admin$”

$service = “SMS_EXECUTIVE”

#$Userlog = “$env:USERPROFILE\Desktop\DP_Repair.log”  #If wants to have the logs on the Desktop session of server where the script is run

#$ServerLog= “\server\Unit$\path” #If wants to have the logs on the server where the script is run

$log = “C:\temp\testlog.txt”  #To save the logs on the temp folder of the server where the script is run

$LogTime = Get-Date -Format “dd-MM-yyyy_hh:mm:ss”

$PatToCMTRACE = “C:\sccm\tools\CMTrace.exe” #Adapt to your server

$PathToDistmgr = “c:\SCCM\Logs\distmgr.log” #Adapt to your server

#Create the function to managed the input on the script

#Create Function for logging

Start-Transcript $Log -Append -NoClobber

Write-Host “###################################”

Write-Host “###################################”

Write-Host “$LogTime $env:computername $env:USERNAME”

Write-Host “###################################”

Write-Host “###################################”

#Create the function for ping confirmation on the remote DP

Function Ping_test (){

if(!(Test-Connection -Cn $DPName -BufferSize 16 -Count 1 -ea 0 -quiet))

{Write-Host “Cannot connect with server $DPName” -ForegroundColor Red -BackgroundColor white | Out-Default

Write-Host “$LogTime $env:computername $env:USERNAME” | Out-Default

}

Else {}#End If

}

#Create function to test Admin$

Function Test_Share (){

if(!(Test-Path  \\$Admin -ea 0))

{Write-Host “Cannot connect with server share $Admin” -ForegroundColor Red -BackgroundColor white | Out-Default

Write-Host “$LogTime $env:computername $env:USERNAME”  | Out-Default}

Else {}#End If

}

#Create function to stop the smsexec service

Function Stop_smsexec(){

Write-Host “Now will restart the service smsexe on server $env:computername” -ForegroundColor Yellow | Out-Default

Write-Host $LogTime | Out-Default

if((Get-Service $service -ErrorAction SilentlyContinue))

{(Stop-Service $service -Confirm -ErrorAction SilentlyContinue) #this will promt a confirmation before restart the service

}

Else {Write-Host “The machine $env:computername has no smsexec service running”

Write-Host “$LogTime $env:computername $env:USERNAME”

Exit 1

}#End If

}

#Timer for service stop, will wait to run the start command till the service is confirmed as stopped

Function Timer()

{

do { Start-Sleep -Milliseconds 200}

until ((get-service $service).status -eq ‘Stopped’)

}

#Create function to start the smsexec service

Function Start_smsexec(){

if(!(Start-Service $service -ea 0))

{Write-Host “SmsExec service started” -ForegroundColor Green -BackgroundColor white  | Out-Default}

Write-Host “$LogTime $env:computername $env:USERNAME’r” | Out-Default

Else {

Write-Host “The SmsExec Service could not be started, will need to restart the machine” -ForegroundColor Red -BackgroundColor white | Out-Default

Write-Host “$LogTime $env:computername $env:USERNAME”  | Out-Default

}#End If

}

#Execution of functions

Ping_test

Test_Share

Stop_smsexec

Timer

Start_smsexec

#Open the cmtrace to review the DP connection path to CMTrace tool and Path to the log to open

& “”$PathtoCMTRACE” ‘$PathToDistmgr'”

Stop-Transcript  #Stop the logging

Enjoy it 🙂

Script to solve errors 53 and 64 on Secondary sites on DistMgr.log

There are several situations where a secondary site may loss communication with one of his child distribution points randomly, while continue communicating OK with other DPs.

Even if we have connectivity, ping resolution and access to Admin$ with the machine account, the situation is not solved on its own, will need to restart the smsexecutive service to restore the communication and stop the errors on the logs.

Failed to make a network connection to \\Server\ADMIN$ (0x35).

Cannot establish connection to [“Display=\\Server\”]MSWNET:[“SMS_SITE=S01”]\\Server\. Error = 53

Copying D:\Foler\File to \\SERVER02\SMSPKGD$\FileFolder, Failed, Win32 Error = 64                SMS_DISTRIBUTION_MANAGER        date 7:53:25 AM      74756 (0x12404)

On my environment this happen kind of frequently, and as the troubleshooting steps are always the same I created a script to automate the solution.

Please test before use extensively, this come with no guaranties so use on your own risk.

I added some controls on the script so the most impacting steps asks before run, if you delete this steps may automate the solution, if integrated with your monitoring tool may do your System Center Configuration Manager tech live more comfortable.

Here are the lines, just copy past on PowerShell and have fun:

#Script to repair the DPs connection events 53 and 64 on secondary site

#On ConfigMgr

#Created on 20 Oct 2016

#Created By Raul del Moral

#**************************************

# Version 2.0 adding the next features:

# Enable control on the script execution so ask for the restart on SmsExec service

# Enable logging on the server with the whole process

# Enable control on SmsExec service so if not detected stops

#**************************************

#Set the variables to use on the script

$DPName =  Read-Host -Prompt ‘Enter the DP name’

if (!$DPName ) {Write-host -ForegroundColor Red -backgroundColor White “Please provide a DP name”

exit(1)}

$Admin = “$DPName\admin$”

$service = “SMS_EXECUTIVE”

#$Userlog = “$env:USERPROFILE\Desktop\DP_Repair.log”  #If wants to have the logs on the Desktop session of server where the script is run

#$ServerLog= “\server\Unit$\path” #If wants to have the logs on the server where the script is run

$log = “C:\temp\testlog.txt”  #To save the logs on the temp folder of the server where the script is run

$LogTime = Get-Date -Format “dd-MM-yyyy_hh:mm:ss”

$PatToCMTRACE = “C:\sccm\tools\CMTrace.exe” #Adapt to your server

$PathToDistmgr = “c:\SCCM\Logs\distmgr.log” #Adapt to your server

#Create the function to managed the input on the script

#Create Function for logging

Start-Transcript $Log -Append -NoClobber

Write-Host “###################################”

Write-Host “###################################”

Write-Host “$LogTime $env:computername $env:USERNAME”

Write-Host “###################################”

Write-Host “###################################”

#Create the function for ping confirmation on the remote DP

Function Ping_test (){

if(!(Test-Connection -Cn $DPName -BufferSize 16 -Count 1 -ea 0 -quiet))

{Write-Host “Cannot connect with server $DPName” -ForegroundColor Red -BackgroundColor white | Out-Default

Write-Host “$LogTime $env:computername $env:USERNAME” | Out-Default

}

Else {}#End If

}

#Create function to test Admin$

Function Test_Share (){

if(!(Test-Path  \\$Admin -ea 0))

{Write-Host “Cannot connect with server share $Admin” -ForegroundColor Red -BackgroundColor white | Out-Default

Write-Host “$LogTime $env:computername $env:USERNAME”  | Out-Default}

Else {}#End If

}

#Create function to stop the smsexec service

Function Stop_smsexec(){

Write-Host “Now will restart the service smsexe on server $env:computername” -ForegroundColor Yellow | Out-Default

Write-Host $LogTime | Out-Default

if((Get-Service $service -ErrorAction SilentlyContinue))

{(Stop-Service $service -Confirm -ErrorAction SilentlyContinue) #this will promt a confirmation before restart the service

}

Else {Write-Host “The machine $env:computername has no smsexec service running”

Write-Host “$LogTime $env:computername $env:USERNAME”

Exit 1

}#End If

}

#Timer for service stop, will wait to run the start command till the service is confirmed as stopped

Function Timer()

{

do { Start-Sleep -Milliseconds 200}

until ((get-service $service).status -eq ‘Stopped’)

}

#Create function to start the smsexec service

Function Start_smsexec(){

if(!(Start-Service $service -ea 0))

{Write-Host “SmsExec service started” -ForegroundColor Green -BackgroundColor white  | Out-Default}

Write-Host “$LogTime $env:computername $env:USERNAME’r” | Out-Default

Else {

Write-Host “The SmsExec Service could not be started, will need to restart the machine” -ForegroundColor Red -BackgroundColor white | Out-Default

Write-Host “$LogTime $env:computername $env:USERNAME”  | Out-Default

}#End If

}

#Execution of functions

Ping_test

Test_Share

Stop_smsexec

Timer

Start_smsexec

#Open the cmtrace to review the DP connection path to CMTrace tool and Path to the log to open

& “”$PathtoCMTRACE” ‘$PathToDistmgr'”

Stop-Transcript  #Stop the logging

Enjoy it 🙂