Skip to content

Instantly share code, notes, and snippets.

@VIRUXE
Last active June 20, 2024 22:47
Show Gist options
  • Save VIRUXE/6347504fa9d84cff52b202425cae01f1 to your computer and use it in GitHub Desktop.
Save VIRUXE/6347504fa9d84cff52b202425cae01f1 to your computer and use it in GitHub Desktop.
Fetch a comma-separated resource list from a FiveM server
try {
$serverCode = $args[0]
if (-not $serverCode) { $serverCode = Read-Host -Prompt 'Please enter the server code' }
$json = Invoke-RestMethod -Uri "https://servers-frontend.fivem.net/api/servers/single/$serverCode"
$serverResources = $json.Data.resources | Sort-Object
Write-Host "Server resources:"
Write-Host ($serverResources -join ', ')
} catch {
Write-Host "An error occurred while retrieving server resources: $_"
} finally {
Write-Host
Write-Host "Press any key to exit..."
[System.Console]::ReadKey($true) | Out-Null
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment