Upload artifacts with script at on_failure stage in pipeline and leave artifacts section untouched. Thus build will use artifacts section on sunny day and on_failure when some test failed.
Upload artifacts with script at on_finish stage in pipeline and remove artifacts. This will behave like finally statement on regardless of tests success.
Wrap tests to PowerShell script and upload test results in the end of this script. As long as upload test results step is happy, the whole test_script is happy so build flow will reach artifact upload stage.