# Bounds are accessible by $Display.Bounds.Width and $Display.Bounds.Height
$Display = Get-PrimaryDisplay
# Use regex to replace text within a file. Quotes are escaped by double quoting ("")
Write-ReplaceContentInFile -Pattern '^ScreenWidth = "(.+)"' -Substitution "ScreenWidth $($Display.Bounds.Width)" -FilePath "$InstallDirectory\preferences.txt"
Write-ReplaceContentInFile -Pattern '^ScreenHeight = "(.+)"' -Substitution "ScreenHeight $($Display.Bounds.Height)" -FilePath "$InstallDirectory\preferences.txt"
# Trim a string down to a specified amount of characters
if ($NewPlayerAlias.Length -gt 16) {
$NewPlayerAlias = $NewPlayerAlias.Substring(0, 16);
}
Write-ReplaceContentInFile -Pattern '^PlayerName = (.+)' -Substitution "PlayerName = $NewPlayerAlias" -FilePath "$InstallDirectory\preferences.txt"