Space Engineers

Space Engineers

Not enough ratings
Dedicated Server - Update Server Files and Mods Easily - PowerShell Script
By Archimedez
A PowerShell script I created to make managing my modded dedicated server a lot easier. It will verify, download and update the Space Engineers Dedicated Server files, and the mods / workshop content specified and provide status and progress for each step.
   
Award
Favorite
Favorited
Unfavorite
Basic Info
This script is intended to run on Windows, utilizing PowerShell and SteamCMD. I've tried to comment each section as best possible.

Grab and Install SteamCMD, running it once to have it initialize itself and create it's folder structure (the SteamCMD page has additional install details if needed).

Edit the Script configurable options per your setup and needs.

Run it! - Note: It may require admin privileges depending on where you run the script from and where your destination folders are. Test without elevation first.

Let me know if you encounter any issues or have any suggestions.

Enjoy! :D
Powershell Script v1.2
Version 1.2
  • Added more user feedback (progress counter, text status)
  • Added Server Files and Mods Download success check (checks returned output for status)
  • Added console beeps upon script completion (script can run for a while if lots of mods are used)
  • Added option to Show / Hide SteamCMD output (clean up output since we have status checks now)

#Created by Archimedez #Last modified 2017-08-01 #Version 1.2 #========================================================================= #Version History #Version 1.2: # Added more user feedback (progress counter, text status) # Added Server Files and Mods Download success check (checks returned output for status) # Added console beeps upon script completion (script can run for a while if lots of mods are used) # Added option to Show / Hide SteamCMD output (clean up output since we have status checks now) #========================================================================= #Version 1.1: # Redirected output to console for better experience in PowerGUI #========================================================================= #Version 1.0: # Created! #========================================================================= cls #steam account username $username = 'SteamUsername' #steam account password $pwd = 'SteamPassword' #steam appID for SE dedicated server $SE_dedi_appID = '298740' #steam appID for SE regular game (workshop content tied to this appID) $SE_reg_appID = '244850' #list of mods to download and copy to server mod folder $mods = @('899070352','877084878','908694199','681276386','885628812','886585270','583415747','316190120','506964853','472832143','646796262','758597413','889485290','677790017','514062285','655922051','562524620','403922024','772650039') #path to your steamCMD install $steamCMD = 'C:\Users\Public\SE_Server\SteamCMD\steamcmd.exe' #path to your SteamCMD SE Workshop content folder $contentFolder = 'C:\Users\Public\SE_Server\SteamCMD\steamapps\workshop\content\244850' #path to your SE dedicated server mods folder $dediModsFolder = 'C:\Users\Public\SE_Server\SteamCMD\steamapps\common\SpaceEngineersDedicatedServer\Content\Mods' #show / hide the output from SteamCMD $showSteamOutput = $false #-------------------------------------------------------------------------------- # END CONFIGURATION # CHANGE NOTHING BELOW UNLESS YOU REALLY KNOW WHAT YOU ARE DOING! SERIOUSLY! :D #-------------------------------------------------------------------------------- #update SE dedicated server files - uses anon to grab. Using WAIT because if we run async, steamCMD sometimes complains that it hasn't shut down properly, since it's running multiple sessions. $updateDedi = $null if (Test-Path out.txt){del out.txt} #New-Item -ItemType file out.txt Write-Host "Validating / Downloading Space Engineers Dedicated Server Files..." -ForegroundColor DarkGreen Start-Process -FilePath $steamCMD -ArgumentList ('+login','anonymous','+app_update',$SE_dedi_appID,'validate','+quit') -Wait -RedirectStandardOutput out.txt -NoNewWindow sleep -Seconds 1 $updateDedi = Get-Content out.txt if ($showSteamOutput -eq $true){Write-Host $updateDedi} #check download/verify was good if ($updateDedi -like "*Success! App '298740' fully installed.") { Write-Host "Validation / Downloading of Space Engineers Dedicated Server Files Complete." -ForegroundColor DarkGreen del out.txt $updateDedi = $null }else{ Write-Host "Validation / Downloading of Space Engineers Dedicated Server Files Failed! Please try running again." -ForegroundColor DarkRed del out.txt $updateDedi = $null break } #download workshop content - requires user/pwd of steam account which owns SE game to get mods. Using WAIT because if we run async, steamCMD sometimes complains that it hasn't shut down properly, since it's running multiple sessions. $modCount = $mods.Count $ii = 0 $modDownloadsGood = $true $updateMods = $null foreach ($mod in $mods){ $ii+=1 Write-Host "Validating / Downloading mod $mod ($ii of $modCount)..." -ForegroundColor DarkGreen #if (Test-Path out.txt){del out.txt} #New-Item -ItemType file out.txt Start-Process -FilePath $steamCMD -ArgumentList ('+login',$username,$pwd,'+workshop_download_item',$SE_reg_appID,$mod,'validate','+quit') -Wait -RedirectStandardOutput out.txt -NoNewWindow sleep -Seconds 1 $updateMods = Get-Content out.txt #check download/verify was good if ($showSteamOutput -eq $true){Write-Host $updateMods} if ($updateMods[7] -like "Success. Downloaded item $mod to *") { Write-Host "Validation / Downloading mod $mod ($ii of $modCount) Complete." -ForegroundColor DarkGreen del out.txt $updateMods = $null }else{ Write-Host "Validation / Downloading mod $mod ($ii of $modCount) Failed! Please try running again." -ForegroundColor DarkRed Write-Host $updateMods del out.txt $updateMods = $null $modDownloadsGood = $false break } sleep -Seconds 1 } #if Mod downloads are good, then copy over. If any were bad, we stop. if ($modDownloadsGood -eq $true){ #rename mods from .bin to .sbm so that SE will recognize and load them $modFolders = Get-ChildItem $contentFolder $ii = 0 foreach ($modFolder in $modFolders){ $ii+=1 $modFolderContents = Get-ChildItem $modFolder.FullName foreach ($modfile in $modFolderContents){ if ($modfile -like "*_legacy.bin"){ [string]$modfileName = $modFolder.FullName + "\" + $modFolder.Name + ".sbm" del $modfileName -ErrorAction SilentlyContinue #if renamed file exists, and bin file exists, mod was updated, so delete old renamed file sleep -Seconds 1 ren -LiteralPath $modfile.FullName -NewName "$modFolder.sbm" } } } sleep -Seconds 5 #pause for 5 sec to ensure file operations are done before continuing #copy over mods to the SE dedicated server mods folder from SE workshop content download storage folder Write-Host "Copying all mods to SE Dedicated Server Mods folder..." -ForegroundColor DarkGreen robocopy $contentFolder $dediModsFolder /E Write-Host "Copying completed." -ForegroundColor DarkGreen } #Completion Beeps [console]::beep(500,300) [console]::beep(500,300) [console]::beep(500,300) [console]::beep(500,300) [console]::beep(500,300)
Powershell Script v1.1
v1.1 ensures No New Window popup for the server and mod updates, and redirects the output to the console (better if running from PowerGUI)

#Created by Archimedez #Last modified 2017-06-04 #Version 1.1 cls #steam account username $username = 'username' #steam account password $pwd = 'password' #steam appID for SE dedicated server $SE_dedi_appID = '298740' #steam appID for SE regular game (workshop content tied to this appID) $SE_reg_appID = '244850' #list of mods to download and copy to server mod folder $mods = @('899070352','877084878','908694199','681276386','885628812','886585270','583415747','316190120','506964853','472832143','646796262','758597413','889485290','677790017','514062285','655922051','562524620','403922024','772650039') #path to your steamCMD install $steamCMD = 'C:\Users\Public\SE_Server\SteamCMD\steamcmd.exe' #path to your SteamCMD SE Workshop content folder $contentFolder = 'C:\Users\Public\SE_Server\SteamCMD\steamapps\workshop\content\244850' #path to your SE dedicated server mods folder $dediModsFolder = 'C:\Users\Public\SE_Server\SteamCMD\steamapps\common\SpaceEngineersDedicatedServer\Content\Mods' #-------------------------------------------------------------------------------- # END CONFIGURATION # CHANGE NOTHING BELOW UNLESS YOU REALLY KNOW WHAT YOU ARE DOING! SERIOUSLY! :D #-------------------------------------------------------------------------------- #update SE dedicated server files - uses anon to grab. Using WAIT because if we run async, steamCMD sometimes complains that it hasn't shut down properly, since it's running multiple sessions. Start-Process -FilePath $steamCMD -ArgumentList ('+login','anonymous','+app_update',$SE_dedi_appID,'validate','+quit') -Wait -RedirectStandardOutput out.txt -NoNewWindow $updateDedi = Get-Content out.txt Write-Host $updateDedi del out.txt $updateDedi = $null #download workshop content - requires user/pwd of steam account which owns SE game to get mods. Using WAIT because if we run async, steamCMD sometimes complains that it hasn't shut down properly, since it's running multiple sessions. foreach ($mod in $mods){ Start-Process -FilePath $steamCMD -ArgumentList ('+login',$username,$pwd,'+workshop_download_item',$SE_reg_appID,$mod,'validate','+quit') -Wait -RedirectStandardOutput out.txt -NoNewWindow $updateMods = Get-Content out.txt Write-Host $updateMods del out.txt $updateMods = $null } #rename mods from .bin to .sbm so that SE will recognize and load them $modFolders = Get-ChildItem $contentFolder foreach ($modFolder in $modFolders){ $modFolderContents = Get-ChildItem $modFolder.FullName foreach ($modfile in $modFolderContents){ if ($modfile -like "*_legacy.bin"){ [string]$modfileName = $modFolder.FullName + "\" + $modFolder.Name + ".sbm" del $modfileName -ErrorAction SilentlyContinue #if renamed file exists, and bin file exists, mod was updated, so delete old renamed file sleep -Seconds 1 ren -LiteralPath $modfile.FullName -NewName "$modFolder.sbm" } } } sleep -Seconds 5 #pause for 5 sec to ensure file operations are done before continuing #copy over mods to the SE dedicated server mods folder from SE workshop content download storage folder robocopy $contentFolder $dediModsFolder /E
Powershell Script v1.0
#Created by Archimedez #Last modified 2017-06-04 #Version 1.0 cls #steam account username $username = 'username' #steam account password $pwd = 'password' #steam appID for SE dedicated server $SE_dedi_appID = '298740' #steam appID for SE regular game (workshop content tied to this appID) $SE_reg_appID = '244850' #list of mods to download and copy to server mod folder $mods = @('899070352','877084878','908694199','681276386','885628812','886585270','583415747','316190120','506964853','472832143','646796262','758597413','889485290','677790017','514062285','655922051','562524620','403922024','772650039') #path to your steamCMD install $steamCMD = 'C:\Users\Public\SE_Server\SteamCMD\steamcmd.exe' #path to your SteamCMD SE Workshop content folder $contentFolder = 'C:\Users\Public\SE_Server\SteamCMD\steamapps\workshop\content\244850' #path to your SE dedicated server mods folder $dediModsFolder = 'C:\Users\Public\SE_Server\SteamCMD\steamapps\common\SpaceEngineersDedicatedServer\Content\Mods' #-------------------------------------------------------------------------------- # END CONFIGURATION # CHANGE NOTHING BELOW UNLESS YOU REALLY KNOW WHAT YOU ARE DOING! SERIOUSLY! :D #-------------------------------------------------------------------------------- #update SE dedicated server files - uses anon to grab. Using WAIT because if we run async, steamCMD sometimes complains that it hasn't shut down properly, since it's running multiple sessions. Start-Process -FilePath $steamCMD -ArgumentList ('+login','anonymous','+app_update',$SE_dedi_appID,'validate','+quit') -Wait #download workshop content - requires user/pwd of steam account which owns SE game to get mods. Using WAIT because if we run async, steamCMD sometimes complains that it hasn't shut down properly, since it's running multiple sessions. foreach ($mod in $mods){ Start-Process -FilePath $steamCMD -ArgumentList ('+login',$username,$pwd,'+workshop_download_item',$SE_reg_appID,$mod,'validate','+quit') -Wait } #rename mods from .bin to .sbm so that SE will recognize and load them $modFolders = Get-ChildItem $contentFolder foreach ($modFolder in $modFolders){ $modFolderContents = Get-ChildItem $modFolder.FullName foreach ($modfile in $modFolderContents){ if ($modfile -like "*_legacy.bin"){ [string]$modfileName = $modFolder.FullName + "\" + $modFolder.Name + ".sbm" del $modfileName -ErrorAction SilentlyContinue #if renamed file exists, and bin file exists, mod was updated, so delete old renamed file sleep -Seconds 1 ren -LiteralPath $modfile.FullName -NewName "$modFolder.sbm" } } } sleep -Seconds 5 #pause for 5 sec to ensure file operations are done before continuing #copy over mods to the SE dedicated server mods folder from SE workshop content download storage folder robocopy $contentFolder $dediModsFolder /E
5 Comments
Robomikel 17 Feb, 2020 @ 9:21pm 
Do you mind if I use parts of your script in my GitHub project? Here is what the function will look like. https://pastebin.com/6EM1c5S2

https://github.com/Robomikel/Steam-Server-Manager
Dux 4 Sep, 2018 @ 8:15am 
Fast way I do it.

in steam:
Library, Tools and to the item in the list.

For me it shows as a update / Download thats needed.. Just go to the downloads and click on it and it was done with the update.
Fluffy The Destroyer 17 Nov, 2017 @ 10:23am 
it doesn't seem to ask me for the 2 way authentication that I have. When it does I only see it in out.txt.
Archimedez  [author] 7 Jun, 2017 @ 1:51pm 
@Darth Vader (Dark), You're welcome! I'm glad it was useful. :)
-pcF' 6 Jun, 2017 @ 5:49pm 
Thanks! You helped me a lot