Skip to main content

Overview

Since there is a full PowerShell runtime built into LANCommander, there are a few custom cmdlets that have been added to simplify common tasks that may be needed when installing or configuring a game. This page covers the definition and use of these cmdlets.

Convert-AspectRatio​

Calculates a resolution for the desired aspect ratio using an input width and height in pixels.

Syntax​

Convert-AspectRatio
-Width <int>
-Height <int>
-AspectRatio <double>

Description​

The Convert-AspectRatio cmdlet is most useful for calculating a resolution for a specific aspect ratio that will fit within a display by either using pillar or letter boxing. For example, some games may only support 4:3 displays and you may want to calculate the correct 4:3 resolution from your 16:9 display. This cmdlet is really useful when paired with Get-PrimaryDisplay.

Example​

Convert-AspectRatio -Width 2560 -Height 1440 -AspectRatio (4 / 3)

# Returns <DisplayResolution>
Width : 1920
Height : 1440

ConvertTo-StringBytes​

Converts an input string into a byte array.

Syntax​

ConvertTo-StringBytes
-Input <string>
-Utf16 <bool>
-BigEndian <bool>
-MaxLength <int>
-MinLength <int>

Description​

ConvertTo-StringBytes is extremely useful for patching strings in binary files. It will take any input string and convert it to a byte array. Length can be controlled using the -MaxLength and -MinLength parameters. Endianness can be set using -BigEndian. If the string must be UTF-16 (easily identifiable as characters separated by 0x00), use -Utf16.

Example​

ConvertTo-StringBytes -Input "Hello, world!" -Utf16 1
72 0 101 0 108 0 108 0 111 0 44 0 32 0 119 0 111 0 114 0 108 0 100 0 33 0

ConvertTo-StringBytes -Input "Hello, world!" -MaxLength
72 101 108 108 111

ConvertTo-StringBytes -Input "Hello" -MaxLength 10 -MinLength 10
72 101 108 108 111 0 0 0 0 0

ConvertTo-StringBytes -Input "Hello" -Utf16 1 -BigEndian 1
0 72 0 101 0 108 0 108 0 111

Edit-PatchBinary​

Patches binary files at a specified offset.

Syntax​

Edit-PatchBinary
-Offset <long>
-Data <byte[]>
-FilePath <string>
-MaxLength <int>
-MinLength <int>

Description​

This cmdlet is useful when a binary file has to be patched at a specific offset. It can be extremely useful when paired with ConvertTo-StringBytes to update a player name in a binary file.

Example​

$bytes = ConvertTo-StringBytes -Input "Master Chief" -Utf16 1 -MaxLength 16 -MinLength 16

Edit-PatchBinary -FilePath "$($env:LOCALAPPDATA)\Microsoft\Halo 2\Saved Games\S0000000\profile" -Offset 0x08 -Data $bytes

Get-GameManifest​

Parses a game's manifest YAML file from the specified install directory.

Syntax​

Get-GameManifest
-Path <string>

Description​

Used to deserialize a game's manifest file (Manifest.yml) from the specified install directory. Returns the game manifest as an object.

Examples​

$manifest = Get-GameManifest -Path "C:\Games\Age of Empires II - The Age of Kings"
Write-Host $manifest.Title

Age of Empires II: The Age of Kings

Get-PrimaryDisplay​

Gets the bounds of the machine's current primary display.

Syntax​

Get-PrimaryDisplay

Description​

The Get-PrimaryDisplay cmdlet takes no parameters and will only return the bounds of the current primary display attached to the machine. This is highly useful in where you might want to automatically set the game's resolution to match the primary display's resolution.

Example​

$Display = Get-PrimaryDisplay

Write-Host "$($Display.Width)x$($Display.Height) @ $($Display.RefreshRate)Hz"

1920x1080 @ 120Hz

Update-IniValue​

Updates the value of an INI file.

Syntax​

Update-IniValue
-Section <string>
-Key <string>
-Value <string>
-FilePath <string>
-WrapValueInQuotes <bool> (optional)

Description​

Update-IniValue should be used when updating the values of an INI file. These files are typically used for configuring games and may be hard to edit using Write-ReplaceContentInFile and regular expressions. INI files are comprised of sections (text surrounded in square brackets, ([Display]), and key-value pairs (Width=1024).

Example​

# Change the resolution
$Display = Get-PrimaryDisplay
Update-IniValue -Section "Display" -Key "Width" -Value "$($Display.Width)" -FilePath "$InstallDirectory\config.ini"

Write-GameManifest​

Serializes a GameManifest object and writes it to disk.

Syntax​

Write-GameManifest
-Path <string>
-Manifest <LANCommander.SDK.GameManifest>

Example​

$manifest = Get-GameManifest -Path "C:\Games\Age of Empires II - The Age of Kings"
$manifest.SortTitle = "Age of Empires 2"

Write-GameManifest -Path "C:\Games\Age of Empires II - The Age of Kings\.lancommander\$($manifest.Id)\Manifest.yml"

Write-ReplaceContentInFile​

Find and replace a string in a text file.

Syntax​

Write-ReplaceContentInFile
-Pattern <string>
-Substitution <string>
-FilePath <string>

Description​

Write-ReplaceContentInFile can be used when you want to edit a text file and replace content. The -Pattern parameter accepts regular expressions.

Example​

# Changes the player's multiplayer name in Call of Duty (2003)
Write-ReplaceContentInFile -Pattern '^seta name (.+)' -Substitution "seta name ""$NewPlayerAlias""" -FilePath "$InstallDirectory\Main\config_mp.cfg"

Get-UserCustomField​

Retrieves the value of a custom field from the user's profile from the server.

Syntax​

Get-UserCustomField
-Name <string>

Description​

This cmdlet can be useful if you have a game that might require a persistent ID attached to your user. Often times games will assign a unique ID to a player upon creation of a profile, and that ID will be used on a server to keep track of stats, inventory, etc. The list of custom fields added to a user can be viewed under their profile in the server's web UI.

Example​

Get-UserCustomField -Name "SteamId"

Get-LocalGame​

Lists the games in the launcher's local library, including whether and where each one is installed.

Syntax​

Get-LocalGame
[-Id <Guid[]>]
[-Title <string>]
[-Installed]

Description​

Each result has the game's Id, Title, SortTitle, Type, BaseGameId, Installed, InstallDirectory, InstalledVersion, InstalledVersionId, InstalledOn and LatestVersion. -Title supports wildcards and is case-insensitive, and -Id can be bound from the pipeline, so $GameManifest | Get-LocalGame returns the current game.

The data comes from the client running the script, so this cmdlet only works in scripts run by the launcher. Run anywhere else, it writes an error and returns nothing.

Example​

# Find where another game is installed
$quake = Get-LocalGame -Title "Quake III Arena" -Installed

if ($quake) {
Copy-Item "$InstallDirectory\maps\*" "$($quake.InstallDirectory)\baseq3\" -Recurse
}

# List every installed game
Get-LocalGame -Installed | Select-Object Title, InstallDirectory

Get-RedistributableOptions​

Retrieves the resolved options for a redistributable assigned to a game.

Syntax​

Get-RedistributableOptions
-Path <string>
-Id <Guid>
-Name <string>

Description​

The Get-RedistributableOptions cmdlet reads the game manifest and returns the resolved option values for the specified redistributable as a nested PSObject. Options are resolved in order: schema defaults, then per-game configured values. Nested options in the schema are represented as nested properties on the returned object.

This cmdlet is useful in [Install](/Scripting/Script Types/Install), [Before Start](/Scripting/Script Types/Before Start), and [Run Wrapper](/Scripting/Script Types/Run Wrapper) scripts where you need to access compatibility shim configuration.

Example​

$options = Get-RedistributableOptions -Path $InstallDirectory -Id $GameManifest.Id -Name "umu-launcher"

# Access nested options
Write-Host $options.Game.GAMEID # "umu-default" or admin-configured value
Write-Host $options.Proton.PROTONPATH # "GE-Proton" or admin-configured value

# Use in a script
if ($options.Proton.PROTONPATH -eq "GE-Proton") {
Write-Host "Using default Proton version"
}

Update-UserCustomField​

Updates the value of a custom field on a users profile.

Syntax​

Update-UserCustomField
-Name <string>
-Value <string>

Description​

The companion to Get-UserCustomField, this cmdlet lets you update or set the value of a custom field on a user's profile directly within your scripts. The most common use case is generating a new user ID on install, writing it to the game's configuration file, and then updating the custom field on the user's profile to store it for subsequent installs.

Example​

Update-UserCustomField -Name "SteamId" -Value "34950494"

ConvertFrom-SerializedBase64​

Deserializes a Base64-encoded YAML string back into an object.

Syntax​

ConvertFrom-SerializedBase64
-Input <string>

Description​

The ConvertFrom-SerializedBase64 cmdlet takes a Base64-encoded string containing YAML-serialized data, decodes it, and deserializes it back into a PowerShell object. This is the companion to ConvertTo-SerializedBase64 and is useful for reading data that was previously serialized and encoded for storage or transport. Accepts pipeline input.

Example​

$data = ConvertFrom-SerializedBase64 -Input "TmFtZTogSGVsbG8="

# Or via pipeline
"TmFtZTogSGVsbG8=" | ConvertFrom-SerializedBase64

ConvertTo-SerializedBase64​

Serializes an object to YAML and encodes it as a Base64 string.

Syntax​

ConvertTo-SerializedBase64
-Input <object>

Description​

The ConvertTo-SerializedBase64 cmdlet takes any object, serializes it to YAML, and then encodes the result as a Base64 string. This is useful for storing or transmitting structured data in a compact, text-safe format. Accepts pipeline input.

Example​

$obj = @{ Name = "Hello"; Value = 42 }
$encoded = ConvertTo-SerializedBase64 -Input $obj

# Or via pipeline
$obj | ConvertTo-SerializedBase64

Edit-PatchGameSpy​

Patches GameSpy master server references in game files to point to a replacement server.

Syntax​

Edit-PatchGameSpy
-Path <string>
-Hostname <string> (optional, default: "openspy.net")
-PublicKey <string> (optional, default: OpenSpy public key)
-BinariesToPatch <string[]> (optional, default: "*.dll", "*.exe")
-TextFilesToPatch <string[]> (optional, default: "*.ini", "*.cfg", "*.conf")

Description​

The Edit-PatchGameSpy cmdlet scans a game's directory for binary and text files that reference GameSpy master servers and patches them to use a replacement server (OpenSpy by default). For binary files, it replaces the gamespy.com hostname and public key at the byte level. For text files, it handles Unreal Engine configuration patterns including UT99 and Unreal 2 master server list entries. The replacement hostname must be exactly 12 characters to match the original gamespy.com length.

Example​

# Patch all GameSpy references to use OpenSpy (default)
Edit-PatchGameSpy -Path "$InstallDirectory"

# Patch with custom hostname and file patterns
Edit-PatchGameSpy -Path "$InstallDirectory" -Hostname "openspy.net" -BinariesToPatch "*.dll","*.exe","*.so"

Get-HorizontalFov​

Calculates a horizontal field of view scaled for the current display's aspect ratio.

Syntax​

Get-HorizontalFov
-Width <int> (optional, defaults to primary display width)
-Height <int> (optional, defaults to primary display height)
-BaseFov <int> (optional, default: 90)

Description​

The Get-HorizontalFov cmdlet calculates a scaled horizontal field of view based on the display's aspect ratio relative to a 4:3 baseline. Many older games use a default 90-degree horizontal FOV designed for 4:3 displays. This cmdlet computes the correct horizontal FOV for wider aspect ratios so that the visible area matches what was intended. If -Width and -Height are not specified, the primary display's resolution is used automatically.

Example​

# Get FOV for the current display with default 90-degree base
$fov = Get-HorizontalFov
Write-Host "Horizontal FOV: $fov"

# Get FOV for a specific resolution with a custom base FOV
$fov = Get-HorizontalFov -Width 2560 -Height 1440 -BaseFov 90
Write-Host "Horizontal FOV: $fov" # Returns 106

Get-VerticalFov​

Calculates a vertical field of view scaled for the current display's aspect ratio.

Syntax​

Get-VerticalFov
-Width <int> (optional, defaults to primary display width)
-Height <int> (optional, defaults to primary display height)
-BaseFov <int> (optional, default: 75)

Description​

The Get-VerticalFov cmdlet calculates a scaled vertical field of view based on the display's aspect ratio relative to a 4:3 baseline. Some games use vertical FOV for their configuration. This cmdlet computes the correct vertical FOV for wider aspect ratios. If -Width and -Height are not specified, the primary display's resolution is used automatically.

Example​

# Get vertical FOV for the current display
$fov = Get-VerticalFov
Write-Host "Vertical FOV: $fov"

# Get vertical FOV for a specific resolution
$fov = Get-VerticalFov -Width 1920 -Height 1080 -BaseFov 75
Write-Host "Vertical FOV: $fov" # Returns 59

Get-SanitizedPath​

Removes invalid filename characters from a path string.

Syntax​

Get-SanitizedPath
-Path <string>

Description​

The Get-SanitizedPath cmdlet strips invalid filename characters from the provided path string. This is useful when constructing file paths from user input or game titles that may contain characters not allowed in file names. Accepts pipeline input.

Example​

$clean = Get-SanitizedPath -Path "Game: The Sequel?"
Write-Host $clean # Returns "Game The Sequel"

# Or via pipeline
"Game: The Sequel?" | Get-SanitizedPath

Expand-LatestArchive​

Downloads and extracts the latest archive for a game, redistributable, or tool.

Syntax​

Expand-LatestArchive
-DestinationPath <string> (optional, defaults to current directory)
-GameId <Guid> (optional, resolved from $GameManifest or $Game)
-RedistributableId <Guid> (optional, resolved from $Redistributable)
-ToolId <Guid> (optional, resolved from $Tool)

Description​

The Expand-LatestArchive cmdlet extracts the latest archive for a game, redistributable, or tool. When run in a server-side packaging context (where $LatestArchivePath is set), it reads directly from the local archive file. When run in a client-side context, it downloads the archive from the LANCommander server via the API. The target ID is automatically resolved from context variables ($Redistributable, $Tool, $GameManifest, or $Game) if not explicitly provided. Returns a DirectoryInfo object pointing to the extraction destination.

Example​

# Extract to the current directory using the context variable
Expand-LatestArchive

# Extract to a specific directory
Expand-LatestArchive -DestinationPath "C:\Games\MyGame"

# Extract a specific game's archive
Expand-LatestArchive -GameId "a1b2c3d4-e5f6-7890-abcd-ef1234567890" -DestinationPath "C:\Staging"

# Extract a redistributable's archive
Expand-LatestArchive -RedistributableId "a1b2c3d4-e5f6-7890-abcd-ef1234567890"

# Extract a tool's archive
Expand-LatestArchive -ToolId "a1b2c3d4-e5f6-7890-abcd-ef1234567890"

New-Package​

Creates a package result object for the packaging pipeline.

Syntax​

New-Package
-Path <string>
-Version <string>
-Changelog <string> (optional)

Description​

The New-Package cmdlet creates a Package object with the specified path, version, and optional changelog, and sets it as the script's return value. This cmdlet is used in [Package](/Scripting/Script Types/Package) scripts to define the output of the packaging process. The -Path parameter should point to the directory containing the package contents to be archived.

Example​

# Create a package from a build output directory
New-Package -Path "C:\Build\Output" -Version "1.0.0" -Changelog "Initial release"

# Minimal usage
New-Package -Path "$BuildDirectory" -Version "2.1.0"

Out-PlayerAvatar​

Downloads the current player's avatar from the server.

Syntax​

Out-PlayerAvatar

Description​

The Out-PlayerAvatar cmdlet retrieves the current authenticated player's avatar from the LANCommander server. Returns the avatar file path as a string. This cmdlet takes no parameters and must be run within a LANCommander script context where the player is authenticated.

Example​

$avatarPath = Out-PlayerAvatar
Write-Host "Avatar saved to: $avatarPath"