$Documents = [Environment]::GetFolderPath('MyDocuments')
$Display = Get-PrimaryDisplay
$VirtualStore = "registry::\HKEY_CURRENT_USER\Software\Classes\VirtualStore\MACHINE\SOFTWARE"
# Use regex to replace text within a file. Quotes are escaped by double quoting ("")
Write-ReplaceContentInFile -Pattern '<Setting Name="optiongrfxres">.*</Setting>' -Substitution "<Setting Name=""optiongrfxres"">$($Display.Bounds.Width) x $($Display.Bounds.Height)</Setting>" -FilePath "$Documents\My Games\Age of Empires 3\Users\New Profile.xml"
Write-ReplaceContentInFile -Pattern '<Setting Name="optiongrfxres">.*</Setting>' -Substitution "<Setting Name=""optiongrfxres"">$($Display.Bounds.Width) x $($Display.Bounds.Height)</Setting>" -FilePath "$Documents\My Games\Age of Empires 3\Users2\New Profile2.xml"
Write-ReplaceContentInFile -Pattern '<Setting Name="optiongrfxres">.*</Setting>' -Substitution "<Setting Name=""optiongrfxres"">$($Display.Bounds.Width) x $($Display.Bounds.Height)</Setting>" -FilePath "$Documents\My Games\Age of Empires 3\Users3\New Profile3.xml"
New-Item -Path "registry::\HKEY_CURRENT_USER\Software\Microsoft\Microsoft Games"
New-Item -Path "registry::\HKEY_CURRENT_USER\Software\Microsoft\Microsoft Games\Age of Empires 3" -Force
New-Item -Path "registry::\HKEY_CURRENT_USER\Software\Microsoft\Microsoft Games\Age of Empires 3\1.0" -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\Software\Microsoft\Microsoft Games\Age of Empires 3\1.0" -Name "FIRSTRUN" -Value 1 -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\Software\Microsoft\Microsoft Games\Age of Empires 3\1.0" -Name "SystemInitialization" -Value "1" -Force
New-Item -Path "registry::\HKEY_CURRENT_USER\Software\Microsoft\Microsoft Games\Age of Empires 3 Expansion Pack" -Force
New-Item -Path "registry::\HKEY_CURRENT_USER\Software\Microsoft\Microsoft Games\Age of Empires 3 Expansion Pack\1.0" -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\Software\Microsoft\Microsoft Games\Age of Empires 3 Expansion Pack\1.0" -Name "FIRSTRUN" -Value 1 -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\Software\Microsoft\Microsoft Games\Age of Empires 3 Expansion Pack\1.0" -Name "SystemInitialization" -Value "1" -Force
New-Item -Path "registry::\HKEY_CURRENT_USER\Software\Microsoft\Microsoft Games\Age of Empires 3 Expansion Pack 2" -Force
New-Item -Path "registry::\HKEY_CURRENT_USER\Software\Microsoft\Microsoft Games\Age of Empires 3 Expansion Pack 2\1.0" -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\Software\Microsoft\Microsoft Games\Age of Empires 3 Expansion Pack 2\1.0" -Name "FIRSTRUN" -Value 1 -Force
New-ItemProperty -Path "registry::\HKEY_CURRENT_USER\Software\Microsoft\Microsoft Games\Age of Empires 3 Expansion Pack 2\1.0" -Name "SystemInitialization" -Value "1" -Force
New-Item -Path "$VirtualStore\WOW6432Node\Microsoft\Microsoft Games"
New-Item -Path "$VirtualStore\WOW6432Node\Microsoft\Microsoft Games\Age of Empires 3"
New-Item -Path "$VirtualStore\WOW6432Node\Microsoft\Microsoft Games\Age of Empires 3\1.0"
New-ItemProperty -Path "$VirtualStore\WOW6432Node\Microsoft\Microsoft Games\Age of Empires 3\1.0" -Name "LangID" -Value 1033 -Force
New-ItemProperty -Path "$VirtualStore\WOW6432Node\Microsoft\Microsoft Games\Age of Empires 3\1.0" -Name "Version" -Value "1.14" -Force
New-ItemProperty -Path "$VirtualStore\WOW6432Node\Microsoft\Microsoft Games\Age of Empires 3\1.0" -Name "SetupPath" -Value "$InstallDirectory" -Force
New-Item -Path "$VirtualStore\WOW6432Node\Microsoft\Microsoft Games\Age of Empires 3 Expansion Pack"
New-Item -Path "$VirtualStore\WOW6432Node\Microsoft\Microsoft Games\Age of Empires 3 Expansion Pack\1.0"
New-ItemProperty -Path "$VirtualStore\WOW6432Node\Microsoft\Microsoft Games\Age of Empires 3 Expansion Pack\1.0" -Name "LangID" -Value 1033 -Force
New-ItemProperty -Path "$VirtualStore\WOW6432Node\Microsoft\Microsoft Games\Age of Empires 3 Expansion Pack\1.0" -Name "Version" -Value "1.06" -Force
New-ItemProperty -Path "$VirtualStore\WOW6432Node\Microsoft\Microsoft Games\Age of Empires 3 Expansion Pack\1.0" -Name "SetupPath" -Value "$InstallDirectory" -Force
New-Item -Path "$VirtualStore\WOW6432Node\Microsoft\Microsoft Games\Age of Empires 3 Expansion Pack 2"
New-Item -Path "$VirtualStore\WOW6432Node\Microsoft\Microsoft Games\Age of Empires 3 Expansion Pack 2\1.0"
New-ItemProperty -Path "$VirtualStore\WOW6432Node\Microsoft\Microsoft Games\Age of Empires 3 Expansion Pack 2\1.0" -Name "LangID" -Value 1033 -Force
New-ItemProperty -Path "$VirtualStore\WOW6432Node\Microsoft\Microsoft Games\Age of Empires 3 Expansion Pack 2\1.0" -Name "Version" -Value "1.03" -Force
New-ItemProperty -Path "$VirtualStore\WOW6432Node\Microsoft\Microsoft Games\Age of Empires 3 Expansion Pack 2\1.0" -Name "SetupPath" -Value "$InstallDirectory" -Force
$Documents = [Environment]::GetFolderPath('MyDocuments')
$Display = Get-PrimaryDisplay
$VirtualStore = "registry::\HKEY_CURRENT_USER\Software\Classes\VirtualStore\MACHINE\SOFTWARE"
Remove-Item -Path "$Documents\My Games\Age of Empires 3" -Recurse -ErrorAction Ignore
Remove-Item -Path "registry::\HKEY_CURRENT_USER\Software\Microsoft\Microsoft Games\Age of Empires 3" -Recurse -ErrorAction Ignore
Remove-Item -Path "registry::\HKEY_CURRENT_USER\Software\Microsoft\Microsoft Games\Age of Empires 3 Expansion Pack" -Recurse -ErrorAction Ignore
Remove-Item -Path "registry::\HKEY_CURRENT_USER\Software\Microsoft\Microsoft Games\Age of Empires 3 Expansion Pack 2" -Recurse -ErrorAction Ignore
Remove-Item -Path "$VirtualStore\WOW6432Node\Microsoft\Microsoft Games\Age of Empires 3" -Recurse -ErrorAction Ignore
Remove-Item -Path "$VirtualStore\WOW6432Node\Microsoft\Microsoft Games\Age of Empires 3 Expansion Pack" -Recurse -ErrorAction Ignore
Remove-Item -Path "$VirtualStore\WOW6432Node\Microsoft\Microsoft Games\Age of Empires 3 Expansion Pack 2" -Recurse -ErrorAction Ignore
$Documents = [Environment]::GetFolderPath('MyDocuments')
if (Test-Path "$Documents\My Games\Age of Empires 3") {
# Nothing
} else {
Copy-Item -Path "$InstallDirectory\ProfileTemplate" -Destination "$Documents\My Games\Age of Empires 3" -Recurse
$Guid = [Guid]::NewGuid().ToString().ToUpper()
$Guid2 = [Guid]::NewGuid().ToString().ToUpper()
$Guid3 = [Guid]::NewGuid().ToString().ToUpper()
Write-ReplaceContentInFile -Pattern '<GUID>.*</GUID>' -Substitution "<GUID>{$Guid}</GUID>" -FilePath "$Documents\My Games\Age of Empires 3\Users\NewProfile.xml"
Write-ReplaceContentInFile -Pattern '<GUID>.*</GUID>' -Substitution "<GUID>{$Guid2}</GUID>" -FilePath "$Documents\My Games\Age of Empires 3\Users2\NewProfile2.xml"
Write-ReplaceContentInFile -Pattern '<GUID>.*</GUID>' -Substitution "<GUID>{$Guid3}</GUID>" -FilePath "$Documents\My Games\Age of Empires 3\Users3\NewProfile3.xml"
}
# Use regex to replace text within a file. Quotes are escaped by double quoting ("")
Write-ReplaceContentInFile -Pattern '<Setting Name="optionskirmishnickname">.*</Setting>' -Substitution "<Setting Name=""optionskirmishnickname"">$NewPlayerAlias</Setting>" -FilePath "$Documents\My Games\Age of Empires 3\Users\NewProfile.xml"
Write-ReplaceContentInFile -Pattern '<Setting Name="optionskirmishnickname">.*</Setting>' -Substitution "<Setting Name=""optionskirmishnickname"">$NewPlayerAlias</Setting>" -FilePath "$Documents\My Games\Age of Empires 3\Users2\NewProfile2.xml"
Write-ReplaceContentInFile -Pattern '<Setting Name="optionskirmishnickname">.*</Setting>' -Substitution "<Setting Name=""optionskirmishnickname"">$NewPlayerAlias</Setting>" -FilePath "$Documents\My Games\Age of Empires 3\Users3\NewProfile3.xml"