#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)