Hat tip to Achim
CLS # nice to have, to clear screen if you use it in the PowerShell ISE
"Löschen aller Server-Sessions..."
$GameSettingsIDs = @()
# User and Password only needed, if you use the file "access" in the folder...
# C:\\Program Files (x86)\\Steam\\steamapps\\common\\RaceRoom Dedicated Server
# ...for protecting Dedicated Server Website
$user = 'YOUR_USERNAME_IN_FILE_ACCESS'
$pass = 'YOUR_USERNAME_IN_FILE_ACCESS'
$pair = "$($user):$($pass)"
$encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair))
$basicAuthValue = "Basic $encodedCreds"
# header only needed if you use upper Authentication
$Headers = @{
Authorization = $basicAuthValue
}
# it think (not tested), the header below is not needed if you do not use Authentication (filde "access" - see above)
$GameSettingsIDs = (Invoke-RestMethod -Uri '<http://localhost:8088/dedi>' -Headers $Headers).GameSetting.Id
if($GameSettingsIDs.Count -lt 1)
{
"Es bestehen keine Server-Sessions!"
exit
}
for($i=0; $i -lt $GameSettingsIDs.Count; $i++)
{
# If you do not use upper Authentication, you can delete Authorisation Part in the header...
$Headers = @{
Authorization = $basicAuthValue
'Content-Type' = 'application/json; charset=utf-8'
}
[System.Environment]::NewLine + "Lösche Session " + $GameSettingsIDs[$i] + "... " +`
(Invoke-WebRequest -Method 'DELETE' -Uri "<http://localhost:8088/dedi/$($GameSettingsIDs[$i])>" -Headers $Headers).StatusDescription
}
[System.Environment]::NewLine
#pause