Unlock Space Engineers DLC

A PowerShell script to unlock Space Engineers DLC, as is sometimes required to run on multiplayer dedicated servers for players who have paid for the content but are unable to use it.

Options:

  • Copy the code below, paste it into PowerShell ISE, and run it.
  • Copy the code below, paste it into a file named SEunlockDLC.ps1, save the file, and then run it with PowerShell.
  • Download the file below and then run it.
    Note: You normally can't run PowerShell from a Downloads folder, so if you download it, move it to your desktop or another location.

This is version 2 of the script. It will attempt to locate SE at the normal install path on a Windows system. If that fails, it will check the Registry location that should list where it is installed. If that fails, it will display a folder selection dialog for you to specify the install location.

# Unlock Space Engineers DLC
# Sometimes required on multiplayer dedicated servers for players who have paid for the content but are unable to use it
# Created by Archi @ FrontRunnerTek.com (this is not an email address)

# Usage: Simply run the script. Edit the $SEinstallDirectory path variable below if you know it and want to speed up the process a bit.

# Manually Specify the install directory, or the script will try to find it, if that fails, it will display a folder selection dialog
$SEinstallDirectory = 'C:\Program Files (x86)\Steam\steamapps\common\SpaceEngineers'

# ========= CHANGE NOTHING BELOW!! =================================================================

Clear-Host
Try {
    If (Test-Path -LiteralPath $SEinstallDirectory -ErrorAction SilentlyContinue) {
        Write-Host "Found $SEinstallDirectory" -ForegroundColor Cyan
    } Else {
        Write-Host "Manually configured path '$SEinstallDirectory' is invalid or inaccessible" -ForegroundColor Red
        $SEinstallDirectory = $null
    }
} Catch {    
    Write-Host "Manually configured path '$SEinstallDirectory' is invalid or inaccessible" -ForegroundColor Red
    $SEinstallDirectory = $null
}


If (!$SEinstallDirectory) {
    Try {
        $SEinstallDirectory = (Get-ItemProperty -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 244850").InstallLocation
        #$SEinstallDirectory = $null # Used for testing
        Try {
            If (Test-Path -LiteralPath $SEinstallDirectory -ErrorAction SilentlyContinue) {
                Write-Host "Found '$SEinstallDirectory' in Steam Registry Entry, testing existance" -ForegroundColor Yellow
            } Else {
                Write-Host "'$SEinstallDirectory' from Steam Registry Entry is invalid or inaccessible" -ForegroundColor Red
                $SEinstallDirectory = $null
            }
        } Catch {    
            Write-Host "'$SEinstallDirectory' from Steam Registry Entry is invalid or inaccessible" -ForegroundColor Red
            $SEinstallDirectory = $null
        }

        Write-Host "Found '$SEinstallDirectory' in Steam Registry Entry is a valid path" -ForegroundColor Green
    } Catch {
        Write-Host "Steam Registry Entry for SE failed to provide a path" -ForegroundColor Red
        $SEinstallDirectory = $null
    }
}

If (!$SEinstallDirectory) {    
    Add-Type -AssemblyName System.Windows.Forms
    $FolderBrowser = New-Object System.Windows.Forms.FolderBrowserDialog
    $FolderBrowser.RootFolder = 'MyComputer'
    $FolderBrowser.Description = "Default methods to locate Space Engineers failed, please select install folder for 'SpaceEngineers'"
    $null = $FolderBrowser.ShowDialog()
    $SEinstallDirectory = $FolderBrowser.SelectedPath
    Try {
        If (Test-Path -LiteralPath $SEinstallDirectory -ErrorAction SilentlyContinue) {
            Write-Host "Selected folder '$SEinstallDirectory'" -ForegroundColor Yellow
        } Else {
            Write-Host "Selected folder '$SEinstallDirectory' is invalid or inaccessible" -ForegroundColor Red
            $SEinstallDirectory = $null
        }
    } Catch {    
        Write-Host "Selected folder '$SEinstallDirectory' is invalid or inaccessible" -ForegroundColor Red
        $SEinstallDirectory = $null
    }
}

If (!$SEinstallDirectory) {
    Write-Host "Unable to locate the SE game folder. Exiting... :(" -ForegroundColor Red
    break
} Else {
    # SBC contains DLC content (blocks, emotes, skins) to unlock
    # SCF are scenarios to unlock
    Write-Host "Scanning for files with DLC locked content..." -ForegroundColor Cyan
    $SEcontentFiles = "$SEinstallDirectory\Content"
    $SEfiles = Get-ChildItem -Path $SEcontentFiles -Recurse -Include *.sbc, *.scf
    ForEach ($SEfile in $SEfiles){
        Write-Host "Checking $SEfile" -ForegroundColor Cyan
        $FileBits = Get-Content -LiteralPath $SEfile.FullName -Raw
        If ($FileBits -like "*<DLC>*") {
            $regExStr = '<DLC>\w+</DLC>'
            $newFileBits = [regex]::Replace($FileBits,$regExStr,'')
            If (Set-Content -LiteralPath $SEfile.FullName -Value $newFileBits -PassThru) {
                Write-Host "Unlocked DLC in: $($SEfile.FullName)" -ForegroundColor Yellow
            }
        } Else {
            Write-Host "Nothing found to unlock in $($SEfile.FullName)" -ForegroundColor Cyan
        }

    }
    Write-Host "Completed!" -ForegroundColor Green
}