Advertisement
Guest User

Install-NameFix.ps1

a guest
Nov 9th, 2021
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <#
  2. .SYNOPSIS
  3.     Installs the licensing and real name fix files, assuming the script is placed in the same directory as the extracted downloaded files.
  4. .EXAMPLE
  5.     . 'C:\Licensing and Real Name Fix File v1.2\Install-NameFix.ps1'
  6.  
  7.     Installs to the default install directory
  8. .EXAMPLE
  9.     . 'C:\Licensing and Real Name Fix File v1.2\Install-NameFix.ps1' -InstallDir 'E:\Program Files\ModifiableWindowsApps\Football Manager 2022'
  10.  
  11.     Installs to a Xbox Game Pass install directory on the E:\ drive
  12. .PARAMETER InstallDir
  13.     The path to the FM install directory - defaults to a Steam installation in $ENV:ProgramFiles
  14. .INPUTS
  15.     String (optional)
  16. .OUTPUTS
  17.     N/A
  18. #>
  19. [CmdletBinding(ConfirmImpact = "Low", SupportsShouldProcess = $True)]
  20. param
  21. (
  22.     [Parameter(Mandatory = $False, HelpMessage = "The FM installation directory")]
  23.     [alias("InstallationDirectory", "Path")]
  24.     [string] $InstallDir = "$ENV:ProgramFiles\Steam\SteamApps\common\Football Manager 2022\"
  25. )
  26.  
  27. $DatabasesPath = Join-Path -Path $InstallDir -ChildPath "data\database\db"
  28. $DatabaseFolders = @(Get-ChildItem -Path $DatabasesPath -Directory)
  29. if ($Null -ne $DatabaseFolders)
  30. {
  31.     forEach ($DatabaseFolder in $DatabaseFolders)
  32.     {
  33.         forEach ($Folder in @("dbc", "edt", "lnc"))
  34.         {
  35.             if ($PSCmdlet.ShouldProcess($DatabaseFolder.FullName, "Remove database folder '$Folder'"))
  36.             {
  37.                 try
  38.                 {
  39.                     Remove-Item -Path (Join-Path -Path $DatabaseFolder.FullName -ChildPath $Folder ) -Recurse -Force
  40.                 }
  41.                 catch
  42.                 {
  43.                     $PSCmdlet.ThrowTerminatingError($_)
  44.                 }
  45.             }
  46.  
  47.             if ($PSCmdlet.ShouldProcess($DatabaseFolder.FullName, "Copy downloaded '$Folder'"))
  48.             {
  49.                 try
  50.                 {
  51.                     Copy-Item -Path (Join-Path -Path $PSScriptRoot -ChildPath $Folder) -Destination $DatabaseFolder -Recurse
  52.                 }
  53.                 catch
  54.                 {
  55.                     $PSCmdlet.ThrowTerminatingError($_)
  56.                 }
  57.             }
  58.         }
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement