In this post we are going to look at automating a Steam server’s maintenance using STEAMcmd and Powershell. The game servers highlighted in the below article will be a collection of Ark game servers.
Slightly different than the usual enterprise IT content one would be familiar with on this blog. However, as of right now I have been running multiple ARK Steam servers for around a year with very minimal downtime. I attribute this long period of time to the fact that the maintenance is all automated using STEAMcmd in combination with PowerShell, thus resulting in very little attention from myself (months apart).
I figure if it’s working well for me, it could also work well for someone else who may be looking to automate their Steam server maintenance without the hassle of configuring ASM (ARK server software) or using some other form of third party software.
Before we get started, please bare in mind this will be focusing on the ARK game server, however if your Steam server uses STEAMCmd for installation, configuration and start-up, this process can be tweaked for the same functionality.
On your server/desktop create a folder on your C: drive, call it anything you want. In my case I called it ‘Startup’ – this is going to be the location for your future start-up scripts / batch files.
After creating the folder locate the SteamCMD folder in your game server (Ark Server) files. In my case the filepath is ‘C:\ArkServer\Engine\Binaries\ThirdParty\SteamCMD\Win64’
Once located create a txt file in the folder location – (I named the file ‘ark1’) and put the following contents inside of it.
app_update 376030 validate
**Make sure to change the install directory (force_install_dir) to the file location of your gaming server
**Also make sure the app_update number is the correct number for your particular gaming server, 376030 is Arks dedicated installation/update number.
In short this text file contains the SteamCMD commands required to initiate a server update check, and if found the server update itself.
Next step involves creating a Batch file in your ‘Start up’ folder – I named the batch file ‘UpdateServer.bat’ – This batch file will be used by the soon to be created PowerShell script to force SteamCMD to run using the commands we laid out in the ‘ark1’ txt file.
The contents of the batch file should be –
steamcmd +runscript ark1.txt
** To save the contents of a new page in notepad as a batch file you need to make sure ‘All Files’ is selected on the ‘Saves as types drop down’ and ‘.bat’ is used at the end of the file name’
As shown in the image below –
After that you are going to want to put your server start-up batch files inside this folder location – as shown in the image above my game servers are Abber, Rag, Rag-PVP, TheCenter and TheIsland.
Just for clarification, an example of the contents of one of these server start-up batch files is –
start ShooterGameServer.exe Aberration_P?SessionName=PVE-NoWipes-Gath6x/Bre6x/Tam3x/Exp10x/S+/Stacking[Clustered]?Port=50025?AltSaveDirectoryName=AbberSaved?
ServerAdminPassword=Helloboss?OverrideOfficialDifficulty=5.0 -clusterid=Arkserver1 -automanagedmods -AutoDestroyStructures -OverrideOfficialDifficulty=5.0 -ForceRespawnDinos
Now you have moved your server startup files into the ‘Start-up’ folder location – you can proceed onto the second to last step of creating the PowerShell script using Windows PowerShell ISE. – I named the script ‘ServerScheduledRestart.ps1’
The contents should include some thing similar to the contents of mine shown below –
In case you’re unfamiliar with PowerShell ISE – please see the image below, this is what your script should look like inside the program, once copied and tweaked you can go to File on the top left and save the ps1 to your ‘Startup’ folder.
Once your script is created and in the right location – it’s time to move onto the final step, which involves setting up a scheduled task to run the ‘ServerScheduledRestart.ps1’ PowerShell script every night or early morning.
Firstly navigate to ‘Task Scheduler’ in your Windows OS
Then click on ‘Create a Basic Task’ on the top right. From here just go through the easy wizard.
Give the scheduled task a name –
Then select the start date and time –
Next select the ‘start a program’ radio button, followed by inputting the following text, including the filepath of your PowerShell script –
After that click Next and Finish.
If done successfully you should see your scheduled task with the following actions as shown in the image below –
Thats it! All the steps are now completed. Your Steam server(s) should now update and restart everyday at the time you chose for the foreseeable future.
Concerning ARK servers, to make sure your mods auto-update on start-up, add ‘-automanagedmods‘ to your start-up batch file.