java.util.NoSuchElementException when running discover now for SCCM Server Instances


Description


When we try to run "Discovery Now" within "SCCM Server Instances" we get "java.util.NoSuchElementException".

Steps to reproduce:
1. Go to Client Software Distribution > SCCM Server Instances > <<YOUR SCCM INSTANCE NAME >> Discover Now
2. Go to Workflow All Contexts > Find the most recent record with version of "Discover SCCM" > Workflow Log to view the errors listed above

Cause

If you have any additional Write-Host statements in the mid server script files, especially

  1. Credentials.psm1
    https://<<YOUR_INSTANCE_NAME>>ecc_agent_script_file.do?sys_id=3f234355376001006b882d465abe5de8&sysparm_record_target=ecc_agent_script_file&sysparm_record_row=2&sysparm_record_rows=3&sysparm_record_list=nameSTARTSWITHcredential%5EORDERBYname

    2. PSRemoteSession.psm1
    https://<<YOUR_INSTANCE_NAME>>/ecc_agent_script_file.do?sys_id=fbebdd359f6213005581decf857fcfae&sysparm_record_target=ecc_agent_script_file&sysparm_record_row=3&sysparm_record_rows=3&sysparm_record_list=nameSTARTSWITHpsremote%5EORDERBYname

These statements will write to the output and this data was being passed to the post processing script of the powershell activity along with the payload which causes this error.

Resolution

Please revert the files to OOB files (especially the above mentioned) or ensure the formatting of the output is intact.