Hat tip to Achim
CLS
"Starten der 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_PASSWORD_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
for($i=0; $i -lt $GameSettingsIDs.Count; $i++)
{
$Headers = @{
Authorization = $basicAuthValue
'Content-Type' = 'application/json; charset=utf-8'
}
#if($GameSettingsIDs[$i] -ne 152272) # lässt diese Session aus
#if($i -lt 5) # nur die ersten 5 starten, da nicht mehr erlaubt sind
if($i -ne 2) # lässt diese Session aus
{
[System.Environment]::NewLine + "Starte Session " + $GameSettingsIDs[$i] + "... " + `
(Invoke-WebRequest -Method 'POST' -Uri '<http://localhost:8088/dedi/start>' -Headers $Headers -Body "{""ProcessId"":$($GameSettingsIDs[$i])}").StatusDescription
}
else
{
[System.Environment]::NewLine + "Session " + $GameSettingsIDs[$i] + " wird nicht gestartet!"
}
}
[System.Environment]::NewLine + [System.Environment]::NewLine
#pause