There is a way to have more than 9999 lines in Command Prompt or Windows PowerShell console. Open Command Prompt or PowerShell and enter:
mode con:cols=120 lines=32766
For some reason, number of lines cannot be set to more than 32766. This is verified to work on Windows Server 2022 and Windows 10.