Fixed #21630 -- Simplified management command discovery

Thanks Aymeric Augustin for the report end the review.