Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- param(
- #Change ath to your FFXI USER folder
- $ffxiDir = 'G:\FFXI\SquareEnix\FINAL FANTASY XI\USER',
- #LIST YOUR MAIN ACCOUNT FIRST
- #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.
- $Account = @(
- #Main account
- 'Creamsicle',
- #Alt accounts
- 'Sorbet',
- 'Milkshak',
- 'Sherbet',
- 'Slurpee',
- 'Dreamsicle',
- 'Fudgsicle'
- ),
- $mainAcct = $account[0],
- $url = 'https://ffera.com/login.php?p=home',
- $urlSearch = 'https://ffera.com/index.php?p=characters',
- $Credentials = (Get-Credential -Message 'Username & Password for FFEra login')
- )
- $i = 0
- While($searchCharacter.Links.Count -le 2) {
- if($i -gt 0) {
- $Credentials = (Get-Credential -Message 'Invalid login credentials. Please enter the correct FFEra login information' -UserName $Credentials.UserName)
- }
- $i++
- #Copy files from FFXI\USER
- $login = Invoke-WebRequest -Uri $url -SessionVariable ffEra
- $login.Forms[0].Fields.username = $Credentials.GetNetworkCredential().UserName
- $login.Forms[0].Fields.password = $Credentials.GetNetworkCredential().Password
- Write-Host -ForegroundColor Yellow 'Logging in...'
- $mainPage = Invoke-WebRequest $url -WebSession $ffEra -Body $login -Method Post
- $searchCharacter = Invoke-WebRequest $URLSearch -WebSession $ffEra
- }
- Write-Host -ForegroundColor Green "`nFFEra login successful!"
- $Values = foreach($obj in $Account) {
- $parseLinks = $searchCharacter.Links | Where {$_.href -like "*characters*"} | where {$_.innerHTML -like "$obj*"}
- if($parseLinks) {
- $idNumber = $parseLinks.href.Split('=')[2]
- $hexValue = "{0:x}" -f [INT]$idNumber
- [PSCUstomobject] @{
- HexValue = $hexValue
- Character = $obj
- }
- }
- else {
- Write-Host -ForegroundColor Yellow "`nUnable to find $obj in FFEra character database."
- }
- }
- $Primary = $Values | Where {$_.Character -like $mainAcct}
- $Alts = $Values | Where {$_.Character -notlike $mainAcct}
- foreach($Alt in $Alts) {
- Rename-Item -Path "$ffxiDir\$($Alt.HexValue)" -NewName "$ffxiDir\old_$($Alt.HexValue)" -Force -ErrorAction SilentlyContinue
- if($input.Character -notlike $mainAcct) {
- Try {
- #Create symbolic link between main account and alts
- New-Item -ItemType SymbolicLink -Path "$ffxiDir" -Name $Alt.HexValue -Value "$ffxiDir\$($Primary.HexValue)" -Force -ErrorAction Stop
- Write-host -ForegroundColor Green "`n Symbolic link created for $($Alt.Character)"
- }
- Catch {
- Write-host -ForegroundColor Yellow "Unable to create symbolic link for $($Alt.Character)"
- }
- }
- }
- Invoke-Item $ffxiDir
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement