Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <#
- .SYNOPSIS
- Installs the licensing and real name fix files, assuming the script is placed in the same directory as the extracted downloaded files.
- .EXAMPLE
- . 'C:\Licensing and Real Name Fix File v1.2\Install-NameFix.ps1'
- Installs to the default install directory
- .EXAMPLE
- . 'C:\Licensing and Real Name Fix File v1.2\Install-NameFix.ps1' -InstallDir 'E:\Program Files\ModifiableWindowsApps\Football Manager 2022'
- Installs to a Xbox Game Pass install directory on the E:\ drive
- .PARAMETER InstallDir
- The path to the FM install directory - defaults to a Steam installation in $ENV:ProgramFiles
- .INPUTS
- String (optional)
- .OUTPUTS
- N/A
- #>
- [CmdletBinding(ConfirmImpact = "Low", SupportsShouldProcess = $True)]
- param
- (
- [Parameter(Mandatory = $False, HelpMessage = "The FM installation directory")]
- [alias("InstallationDirectory", "Path")]
- [string] $InstallDir = "$ENV:ProgramFiles\Steam\SteamApps\common\Football Manager 2022\"
- )
- $DatabasesPath = Join-Path -Path $InstallDir -ChildPath "data\database\db"
- $DatabaseFolders = @(Get-ChildItem -Path $DatabasesPath -Directory)
- if ($Null -ne $DatabaseFolders)
- {
- forEach ($DatabaseFolder in $DatabaseFolders)
- {
- forEach ($Folder in @("dbc", "edt", "lnc"))
- {
- if ($PSCmdlet.ShouldProcess($DatabaseFolder.FullName, "Remove database folder '$Folder'"))
- {
- try
- {
- Remove-Item -Path (Join-Path -Path $DatabaseFolder.FullName -ChildPath $Folder ) -Recurse -Force
- }
- catch
- {
- $PSCmdlet.ThrowTerminatingError($_)
- }
- }
- if ($PSCmdlet.ShouldProcess($DatabaseFolder.FullName, "Copy downloaded '$Folder'"))
- {
- try
- {
- Copy-Item -Path (Join-Path -Path $PSScriptRoot -ChildPath $Folder) -Destination $DatabaseFolder -Recurse
- }
- catch
- {
- $PSCmdlet.ThrowTerminatingError($_)
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement