JFLarvoire / SysToolsLib

A library of Windows and Linux system management tools
Apache License 2.0
314 stars 93 forks source link

Get-Console.ps1 error #25

Closed he852100 closed 4 years ago

he852100 commented 4 years ago
PS /root/tools> ./Get-Console          
MethodInvocationException: /root/tools/Get-Console.ps1
Line |                                                         
 306 |   $buffer = $Host.UI.RawUI.GetBufferContents($rec)
     |   ^ Exception calling "GetBufferContents" with "1"
     | argument(s): "The method or operation is not                
     | implemented."

InvalidOperation: /root/tools/Get-Console.ps1
Line |
 312 |     $c = $buffer[$iLastLine, $j].Character
     |     ^ Cannot index into a null array.                  
InvalidOperation: /root/tools/Get-Console.ps1
Line |                                                         
 312 |     $c = $buffer[$iLastLine, $j].Character
     |     ^ Cannot index into a null array.
PSVersion                      7.0.0-daily.20191206
PSEdition                      Core
GitCommitId                    7.0.0-daily.20191206           
OS                             Linux 4.9.112-perf #1 SMP PRE… Platform
Unix
JFLarvoire commented 4 years ago

Interesting issue: I had never tested any of my PowerShell scripts in PS Core for Linux. Juste in case, I first checked the script with PS Core 7.0.0-preview.6 in Windows: It works fine, both in the old Console, and in the new Terminal. Then indeed with PS Core for Linux in an LXSS bash window, I get the same exception that you got. But I'm afraid this is not a problem in Get-Console.ps1, but rather it's a problem in PS core for Linux, or more likely in .NET Core for Linux: Obviously it's still missing APIs compared to the Windows version. I think you should post this instead in PS Core issues or in .NET Core issues.