Advertisement
Guest User

FFXI-CopyMacros

a guest
Jan 26th, 2020
756
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.96 KB | None | 0 0
  1. param(
  2.  
  3. #Change ath to your FFXI USER folder
  4. $ffxiDir = 'G:\FFXI\SquareEnix\FINAL FANTASY XI\USER',
  5.  
  6. #LIST YOUR MAIN ACCOUNT FIRST
  7. #Remove any account not involved in your currently desired copy process, this will overwrite all listed characters macro sets with the FIRST listed character's macro sets.
  8. $Account = @(
  9.  
  10. #Main account
  11. 'Creamsicle',
  12.  
  13. #Alt accounts
  14. 'Sorbet',
  15. 'Milkshak',
  16. 'Sherbet',
  17. 'Slurpee',
  18. 'Dreamsicle',
  19. 'Fudgsicle'
  20. ),
  21.  
  22. $mainAcct = $account[0],
  23.  
  24. $url = 'https://ffera.com/login.php?p=home',
  25. $urlSearch = 'https://ffera.com/index.php?p=characters',
  26. $Credentials = (Get-Credential -Message 'Username & Password for FFEra login')
  27. )
  28.  
  29. $i = 0
  30.  
  31. While($searchCharacter.Links.Count -le 2) {
  32.  
  33. if($i -gt 0) {
  34.  
  35. $Credentials = (Get-Credential -Message 'Invalid login credentials. Please enter the correct FFEra login information' -UserName $Credentials.UserName)
  36. }
  37.  
  38. $i++
  39.  
  40. #Copy files from FFXI\USER
  41. $login = Invoke-WebRequest -Uri $url -SessionVariable ffEra
  42. $login.Forms[0].Fields.username = $Credentials.GetNetworkCredential().UserName
  43. $login.Forms[0].Fields.password = $Credentials.GetNetworkCredential().Password
  44.  
  45. Write-Host -ForegroundColor Yellow 'Logging in...'
  46. $mainPage = Invoke-WebRequest $url -WebSession $ffEra -Body $login -Method Post
  47. $searchCharacter = Invoke-WebRequest $URLSearch -WebSession $ffEra
  48. }
  49.  
  50. Write-Host -ForegroundColor Green "`nFFEra login successful!"
  51.  
  52. $Values = foreach($obj in $Account) {
  53.  
  54. $parseLinks = $searchCharacter.Links | Where {$_.href -like "*characters*"} | where {$_.innerHTML -like "$obj*"}
  55.  
  56. if($parseLinks) {
  57.  
  58. $idNumber = $parseLinks.href.Split('=')[2]
  59. $hexValue = "{0:x}" -f [INT]$idNumber
  60. [PSCUstomobject] @{
  61.  
  62. HexValue = $hexValue
  63. Character = $obj
  64. }
  65. }
  66.  
  67. else {
  68.  
  69. Write-Host -ForegroundColor Yellow "`nUnable to find $obj in FFEra character database."
  70. }
  71. }
  72.  
  73. $Primary = $Values | Where {$_.Character -like $mainAcct}
  74. $Alts = $Values | Where {$_.Character -notlike $mainAcct}
  75.  
  76. foreach($Alt in $Alts) {
  77.  
  78. Rename-Item -Path "$ffxiDir\$($Alt.HexValue)" -NewName "$ffxiDir\old_$($Alt.HexValue)" -Force -ErrorAction SilentlyContinue
  79.  
  80. if($input.Character -notlike $mainAcct) {
  81.  
  82. Try {
  83.  
  84. #Create symbolic link between main account and alts
  85. New-Item -ItemType SymbolicLink -Path "$ffxiDir" -Name $Alt.HexValue -Value "$ffxiDir\$($Primary.HexValue)" -Force -ErrorAction Stop
  86.  
  87. Write-host -ForegroundColor Green "`n Symbolic link created for $($Alt.Character)"
  88. }
  89.  
  90. Catch {
  91.  
  92. Write-host -ForegroundColor Yellow "Unable to create symbolic link for $($Alt.Character)"
  93. }
  94. }
  95. }
  96.  
  97. Invoke-Item $ffxiDir
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement