Closed ThePoShWolf closed 3 years ago
Whenever I use the Get-SteamServerInfo function against my self hosted Valheim server, it always displays an error.
Get-SteamServerInfo
Get-SteamServerInfo -IPAddress <server ip> -Port <server port>
Error message:
MethodInvocationException: C:\Users\antwon\Documents\PowerShell\Modules\SteamPS\3.2.0\Private\Server\Get-PacketString.ps1:38 Line | 38 | [System.Text.Encoding]::UTF8.GetString($stringBytes) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | Exception calling "GetString" with "1" argument(s): "Array cannot be null. (Parameter 'bytes')"
However, it does display information:
Protocol : 17 ServerName : <map name> Map : <map name> InstallDir : valheim GameName : AppID : 0 Players : 0 MaxPlayers : 10 Bots : 0 ServerType : Dedicated Environment : Windows Visibility : Private VAC : Unsecured Version : 1.0.0.0 ExtraDataFlag : 177 IPAddress : <redacted> Port : <redacted>
I would expect it not to error.
Get-Module -Name SteamPS -ListAvailable | >> Select-Object -Property Name, Version Name Version ---- ------- SteamPS 3.2.0 $PSVersionTable | Out-String Name Value ---- ----- PSVersion 7.1.3 PSEdition Core GitCommitId 7.1.3 OS Microsoft Windows 10.0.19041 Platform Win32NT PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…} PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1 WSManStackVersion 3.0
I did also try this on Windows PowerShell 5.1, same error.
I believe the resolution to this is to simply add an if statement to line 38 on Get-PacketString:
Get-PacketString
if ($stringBytes.Count -gt 0) { [System.Text.Encoding]::UTF8.GetString($stringBytes) }
Thanks @ThePoShWolf. I am releasing a patch with your resolution soon.
Best, Frederik
Sweet. Thanks for the fix and for the module! 👍
Describe "Module Bug or Issue"
Whenever I use the
Get-SteamServerInfo
function against my self hosted Valheim server, it always displays an error.Context "The Problem"
Error message:
However, it does display information:
Context "Expected Behavior"
I would expect it not to error.
Context "Additional Information"
I did also try this on Windows PowerShell 5.1, same error.
I believe the resolution to this is to simply add an if statement to line 38 on
Get-PacketString
: