Powershell implementation of Query and Rcon for Source and Goldsource games.
Open powershell or pwsh and type:
Install-Module -Name PSSourceQuery -Repository PSGallery -Scope CurrentUser -VerboseIf prompted to trust the repository, hit Y and enter.
-Address may be a DNS or IP address.
-Verbose turns on verbose output for debugging.
Import-Module PSSourceQuery
# Source Engine
# A2S_INFO query. Returns a hashtable of server metadata
SourceQuery -Address $address -Port $port -Engine 'Source' -Type 'info'
# A2S_PLAYER query. Returns a hashtable of players
SourceQuery -Address $address -Port $port -Engine 'Source' -Type 'players'
# A2S_RULES query, Returns a hashtable of server cvars
SourceQuery -Address $address -Port $port -Engine 'Source' -Type 'rules'
# A2A_PING query (deprecated). Returns a hashtable of whether the ping was successful
SourceQuery -Address $address -Port $port -Engine 'Source' -Type 'ping'
# Goldsource Engine
# A2S_INFO query - Returns a hashtable of server metadata
SourceQuery -Address $address -Port $port -Engine 'Goldsource' -Type 'info'
# A2S_PLAYER query. Returns a hashtable of players
SourceQuery -Address $address -Port $port -Engine 'Goldsource' -Type 'players'
# A2S_RULES query, Returns a hashtable of server cvars
SourceQuery -Address $address -Port $port -Engine 'Goldsource' -Type 'rules'
# A2A_PING query (deprecated). Returns a hashtable of whether the ping was successful
SourceQuery -Address $address -Port $port -Engine 'Goldsource' -Type 'ping'Import-Module PSSourceQuery
# Source Engine
SourceRcon -Address $address -Port $port -Password $rcon_password -Command 'status'
# Goldsource Engine
GoldsourceRcon -Address $address -Port $port -Password $rcon_password -Command 'status'Powershellv5 and later orPowershell Core(akapwsh)
| Engine | Games |
|---|---|
Source (srcds) |
cs2, csgo, hl2mp, left4dead2 |
Goldsource (hlds) |
cstrike, czero, valve. Should work for all hlds games. |
The functions will probably work on a lot more games than those in the list.
A2A_PING is no longer supported on Counter Strike: Source and Team Fortress 2 servers, and is considered a deprecated feature. See official documentation here for more information.
The functions are stateless - that is, SourceQuery, SourceRcon, and GoldsourceRcon are pure functions, storing no authentication or challenge states. This is to be expected for Source Queries, but not for Rcon. A possible future area of improvement would be to make SourceRcon and GoldsourceRcon construct and return a stateful Rcon object, that would improve client performance especially when multiple rcon commands need to be executed in sequence.