$Documents = [Environment]::GetFolderPath('MyDocuments')
Remove-Item "$Documents\ETLegacy" -Recurse -ErrorAction Ignore
$Documents = [Environment]::GetFolderPath('MyDocuments')
$NewPlayerAlias = $NewPlayerAlias.Split([IO.Path]::GetInvalidFileNameChars()) -join '_'
$OldPlayerAlias = $OldPlayerAlias.Split([IO.Path]::GetInvalidFileNameChars()) -join '_'
if ((Test-Path -Path "$Documents\ETLegacy\legacy\profiles\$OldPlayerAlias") -And ($OldPlayerAlias -ne $NewPlayerAlias)) {
Rename-Item "$Documents\ETLegacy\legacy\profiles\$OldPlayerAlias" "$NewPlayerAlias"
} else {
Copy-Item -Path "$InstallDirectory\profile" -Destination "$Documents\ETLegacy" -Recurse
Rename-Item "$Documents\ETLegacy\legacy\profiles\DoctorDalek" "$NewPlayerAlias"
}
Write-ReplaceContentInFile -Pattern '^seta name "(.+)"' -Substitution "seta name ""$NewPlayerAlias""" -FilePath "$Documents\ETLegacy\legacy\profiles\$NewPlayerAlias\etconfig.cfg"
"""$NewPlayerAlias""" | Out-File -FilePath "$Documents\ETLegacy\legacy\profiles\defaultprofile.dat" -Encoding ASCII -NoNewLine
"""$NewPlayerAlias""" | Out-File -FilePath "$Documents\ETLegacy\legacy\profiles\$NewPlayerAlias\profile.dat" -Encoding ASCII -NoNewLine