Did the commands in https://learn.microsoft.com/en-us/azure/migrate/troubleshoot-discovery#error-10002-scriptexecutiontimedoutonvm output the result in a few seconds?
Please assign more Cores and/or Memory to your Sever and run the commands again.
Hope this helps!
Accept Answer and Upvote, if any of the above helped, this thread can help others in the community looking for remediation for similar issues.