PowerShell Auto‑Update & Launch Script
server.ps1 is a single‑file utility that installs Java (if missing), fetches the requested or latest minecraft_server-<version>.jar, accepts the EULA on your behalf (optional), and starts the server with sensible defaults—all on Windows via PowerShell.
- Java bootstrap – Installs OpenJDK 21 automatically through winget when no compatible Java runtime is found.
- Version‑aware download – Downloads the specified version or the latest release. The Mojang version manifest is queried only when the latest version is requested, avoiding unnecessary network calls.
- EULA automation – Pass
-Eula yes|trueto skip the interactive prompt and writeeula=trueto eula.txt. - 16 GB heap & nogui by default – Tweakable with
-MinMemory,-MaxMemory, and-Guiswitches. - Modular functions – Each major step lives in its own function for easy maintenance and reuse.
| Item | Recommended / Required |
|---|---|
| OS | Windows 10 / 11 |
| Shell | PowerShell 7.x or Windows PowerShell 5.1 |
| Package manager | winget (bundled with Windows App Installer) |
| Network | HTTPS access to launchermeta.mojang.com |
Heads‑up: If winget is unavailable, pre‑install Java 21 and make sure it is on PATH.
# Run from the script’s directory – grabs the latest build & auto‑accepts the EULA
./server.ps1 -Eula yesFirst‑run flow:
- Check for Java; install if missing.
- Resolve the latest version and download the JAR if not present.
- Ensure eula.txt exists and contains
eula=true(auto or interactive). - Launch the server with the requested heap size.
| Parameter | Type | Default | Description |
|---|---|---|---|
-Version |
string |
latest | Example: "1.20.4" to pin a version. |
-MinMemory |
string |
16G |
Passed to Java as -Xms. |
-MaxMemory |
string |
16G |
Passed to Java as -Xmx. |
-Gui |
switch |
off | Show the legacy server GUI instead of nogui. |
-Eula |
string |
empty | yes or true = non‑interactive EULA acceptance. |
./server.ps1 -Version 1.20.4 -MinMemory 8G -MaxMemory 8G -Eula yes./server.ps1 -MinMemory 4G -MaxMemory 4G -Gui -Eula yes./server.ps1Running a Minecraft server requires acceptance of the Mojang EULA. The script supports:
-Eula yes|true– immediately writeseula=true.- No
-Eulaflag – prompts for confirmation.
Read the full EULA here: https://aka.ms/MinecraftEULA.
- Only triggers
winget install Microsoft.OpenJDK.21when Java is missing. - Refreshes the current session’s PATH so the new Java is available right away.
server.ps1
├─ Install-Java # Java presence check & winget install
├─ Get-Manifest # Fetches version manifest (latest only)
├─ Ensure-ServerJar # Verifies & downloads the server JAR
├─ Ensure-Eula # Verifies & updates eula.txt
└─ Main # Orchestrates steps & launches Java
- Backup your world—the script does not guard against map corruption.
- Future changes in Mojang’s API or download host can break the script.
- Linux/macOS are not supported; use a shell script or container solution instead.
Licensed under the Apache License 2.0. See the LICENSE file for full text.
- Open an issue or pull request.
- When reporting bugs, include your PowerShell version, Windows build, and the exact command line you ran.
Satoru Yoshihara (Vaduz) @Vaduzjp