Skip to content

Powershell implementation of Query and Rcon for Source and Goldsource games.

License

Notifications You must be signed in to change notification settings

startersclan/PSSourceQuery

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PSSourceQuery

github-actions github-release powershell-gallery-release

Powershell implementation of Query and Rcon for Source and Goldsource games.

Install

Open powershell or pwsh and type:

Install-Module -Name PSSourceQuery -Repository PSGallery -Scope CurrentUser -Verbose

If prompted to trust the repository, hit Y and enter.

Usage

-Address may be a DNS or IP address.

-Verbose turns on verbose output for debugging.

Query

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'

Rcon

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'

FAQ

Q: Prerequisites?

Q: Verified games?

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.

Q: ping query not working for some games?

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.

Notes

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.