# PowerShell Kill Process Clear-Host $ShooterGameprocess = Get-Process ShooterGameServer #CHANGE ME - Folder where SteamCMD is: $steamcmdFolder="D:\Server\ark-pvp" #CHANGE ME - Folder for Ark Survival eveloved $arksurvivalFolder="D:\Server\ark-pvp\ark" #not used anymore as the update is done in this script $arksurvivalSteamScript="update_ark.txt" #CHANGE ME - Startup arguments for the server $arkSurvivalStartArguments="TheIsland?QueryPort=27016?MultiHome=serverip?RCONEnabled=true?RCONPort=27116?MaxPlayers=100?Port=7778?listen -nosteamclient -game -server -servergamelog -log" #CHANGE ME - path to mrcon.exe $mcrconExec="D:\Server\mcrcon\mcrcon.exe" #CHANGE ME -RCON IP (same as the server ip) $rconIP="serverip" #CHANGE ME - RCON Port $rconPort=27116 #CHANGE ME - RCON Password $rconPassword="password" #The ID of the App Your Updating $steamAppID="376030" # Without clearing cache app_info_update may return old informations! $clearCache=1 $scriptPath = Split-Path -parent $MyInvocation.MyCommand.Definition $dataPath = $scriptPath+"\data" $steamcmdExec = $steamcmdFolder+"\steamcmd.exe" $steamcmdCache = $steamcmdFolder+"\appcache" $latestAppInfo = $dataPath+"\latestappinfo.json" $updateinprogress = $arksurvivalFolder+"\updateinprogress.dat" $latestAvailableUpdate = $dataPath+"\latestavailableupdate.txt" $latestInstalledUpdate = $dataPath+"\latestinstalledupdate.txt" If (Test-Path $updateinprogress) { Write-Host Update is already in progress } else { Get-Date | Out-File $updateinprogress Write-Host Creating data Directory New-Item -Force -ItemType directory -Path $dataPath If ($clearCache) { Write-Host Removing Cache Folder Remove-Item $steamcmdCache -Force -Recurse } Write-Host Checking for an update & $steamcmdExec +login anonymous +app_info_update 1 +app_info_print $steamAppID +app_info_print $steamAppID +app_info_print 376030 +app_info_print 376030 +quit | Out-File $latestAppInfo Get-Content $latestAppInfo -RAW | Select-String -pattern '(?m)"public"\s*\{\s*"buildid"\s*"\d{6,}"' -AllMatches | %{$_.matches[0].value} | Select-String -pattern '\d{6,}' -AllMatches | %{$_.matches} | %{$_.value} | Out-File $latestAvailableUpdate If (Test-Path $latestInstalledUpdate) { $installedVersion = Get-Content $latestInstalledUpdate } Else { $installedVersion = 0 } $availableVersion = Get-Content $latestAvailableUpdate if ($installedVersion -ne $availableVersion) { Write-Host Current version: $installedVersion - Latest version: $availableVersion Write-Host Update Available #Server Message 1 hr warning #& $mcrconExec -c -H $rconIP -P $rconPort -p $rconPassword "broadcast Ein Neues Update ist verfuegbar, Server startet in 60 Minuten neu..." #Write-Host 1 hr warning given #Start-Sleep -s 900 #Server Message 45 minute warning #& $mcrconExec -c -H $rconIP -P $rconPort -p $rconPassword "broadcast Neues Update verfuegbar, Server startet in 45 Minuten neu..." #Write-Host 45 min warning given #Start-Sleep -s 900 #Server Message 30 minute warning #& $mcrconExec -c -H $rconIP -P $rconPort -p $rconPassword "broadcast Neues Update verfuegbar, Server startet in 30 Minuten neu... Es wird Zeit nach Hause zu gehen ;)" #Write-Host 30 min warning given #Start-Sleep -s 900 #Server Message 15 minute warning #& $mcrconExec -c -H $rconIP -P $rconPort -p $rconPassword "broadcast Neues Update verfuegbar, Server startet in 15 Minuten neu... Ihr solltet wirklich darueber nachdenken, an einen sicheren Ort zu gehen!" #Write-Host 15 min warning given #Start-Sleep -s 300 #Server Message 10 minute warning #& $mcrconExec -c -H $rconIP -P $rconPort -p $rconPassword "broadcast Neues Update verfuegbar, Server startet in 10 Minuten neu... Wenn der Server heruntergefahren ist, dauert es etwa 5-10 Minuten bis er wieder Online ist." #Start-Sleep -s 300 #Server Message 5 minute warning given #& $mcrconExec -c -H $rconIP -P $rconPort -p $rconPassword "broadcast Neues Update verfuegbar, Server startet in 5 Minuten neu... Jetzt aber schnell nach Hause!" #Start-Sleep -s 240 #Server Message 1 minute Warning & $mcrconExec -c -H $rconIP -P $rconPort -p $rconPassword "broadcast Neues Update verfuegbar, Server startet in 1 Minuten neu... Nicht vergessen ihr muesst euren Client auch Updaten - Bis gleich ;)" Write-Host 1 min warning given Start-Sleep -s 10 #Save World admin command & $mcrconExec -c -H $rconIP -P $rconPort -p $rconPassword "saveworld" Start-Sleep -s 10 Write-Host world saving #Server Message Shutting Down & $mcrconExec -c -H $rconIP -P $rconPort -p $rconPassword "broadcast Welt gespeichert und der Neustart folgt jetzt." Start-Sleep -s 15 #Server Admin Command Quit Write-Host Quit Server & $mcrconExec -c -H $rconIP -P $rconPort -p $rconPassword "quit" #Kill The Server by Ending the process (Get-WmiObject Win32_Process | Where-Object { $_.Path.StartsWith('D:\Server\ark-pvp\ark\ShooterGame\Binaries\Win64') }).Terminate() Start-Sleep -s 10 #update server Write-Host Update Script Initialising #CHANGE ME - you need to enter & $steamcmdExec +login anonymous +force_install_dir $arksurvivalFolder +app_update 376030 +exit #restart server Write-Host Restarting Server! & $arksurvivalFolder"\ShooterGame\Binaries\Win64\ShooterGameServer.exe" $arkSurvivalStartArguments #update current version $availableVersion | Out-File $latestInstalledUpdate #remove currently being updated block Write-Host Update Done! Remove-Item $updateinprogress -Force } ELSE { #remove currently being updated block Remove-Item $updateinprogress -Force Write-Host Running Latest Version $installedVersion Write-Host MOTD message Displayed Start-Sleep -s 900 # Server Message MOTD & $mcrconExec -c -H $rconIP -P $rconPort -p $rconPassword "broadcast Wenn es dir bei uns gefaellt, schau doch mal auf unserem TS und im Forum vorbei." Write-Host MOTD teamspeak message Displayed } }