How to move all accounts from one platform to another using PACLI and Powershell

How to move all accounts from one platform to another using PACLI and Powershell

100
Created On 11/10/26 10:55 AM - Last Modified 11/10/26 15:52 PM


Objective


There may be a reason that you need to move all accounts associated with PlatformA to PlatformB.  For example, you are using the WebConfigFile Service Account Platform, but want to upgrade to the new WebFile platform, or you currently have all accounts associated with the Out of Box platform and would instead like to duplicate the platform and move all current accounts over to the duplicated platform and make setting changes.  If the accounts to be moved over are standard target accounts, there are several ways to accomplish this including using the RestAPI or multi-selecting the accounts in the PVWA Accounts View and editing them all at once.  With Service Account Platforms (Usages), however, the RestAPI as of 11.1 does not support modifying them, and you are not able to multi-select them in the PVWA.

Using PowerShell and PACLI you can bulk update your accounts as outlines below.


Environment


v9.0;v9.1;v9.2;9.3;9.5;9.6;9.7;9.8;9.9;9.9.5;9.10;10.0;10.1;10.2;10.3;10.4;10.5;10.6;10.7;10.8;10.9;10.10;11.1;11

Procedure


***NOTE: Before utilizing the script below in your production environment, it should be thoroughly tested to ensure the expected outcome is received***
  1. Copy the code sample to your system.  I recommend using PowerShell ISE because it makes making the necessary modifications easy.
  2. Sample Code:
  3. $VerbosePreference = 'Continue'  #Set to 'SilentlyContinue' to not show Verbose output
    
    $vaultaddress = <vaultaddress>
    $vaultuser = <vaultuser>
    $vaultuserpass = <vaultuserpassword>
    $oldplatform = <oldplatform PolicyID> #Make sure to match case.  IE WebConfigFile
    $newplatform = <newplatform PolicyID> #Make sure to match case.  IE WebFile
    
    Write-Host 'Beginning'
    .\PACLI Init | Out-Null
    .\PACLI define 'vault="Vault"' "address=$vaultaddress" | Out-Null
    .\PACLI default 'vault="Vault"' user="$vaultuser" | Out-Null
    .\PACLI logon "password=$vaultuserpass" | Out-Null
    
    .\PACLI FINDFILES 'SAFE=""' 'FOLDER=""' 'CATEGORYIDLIST=POLICYID' "CATEGORYVALUES=$oldplatform" 'OUTPUT(ENCLOSE,NAME,SAFE,FOLDER,FILECATEGORIES)' |
    ConvertFrom-Csv -Header NAME,SAFE,FOLDER,FILECATEGORIES |
    Sort-Object Safe |
    Set-Variable -Name AccountsToMigrate
    If ($AccountsToMigrate) {
        $AccountsToMigrate |
        ForEach-Object {
            Write-Verbose "$_"
            If ($opensafe -eq $null) {
                Write-Verbose "Opening First Safe: $($_.safe)"
                .\PACLI opensafe  "SAFE=`"$($_.safe)`"" | Out-Null
                $opensafe = $_.safe
            }
            ElseIf ($opensafe -ne $_.safe) {
                Write-Verbose "Closing Safe: $opensafe"
                .\PACLI closesafe "SAFE=`"$opensafe`"" | Out-Null
    
                Write-Verbose "Opening Safe: $($_.safe)"
                .\PACLI opensafe  "SAFE=`"$($_.safe)`"" | Out-Null
                $opensafe = $_.safe
            }
            Write-Host "Updating PolicyID for '$($_.safe)','$($_.folder)','$($_.name)'"
            .\PACLI UPDATEFILECATEGORY "SAFE=`"$($_.safe)`"" "FOLDER=`"$($_.folder)`"" "FILE=`"$($_.name)`"" "CATEGORY=`"PolicyID`"" "VALUE=`"$newplatform`"" | Out-Null
        }
    
        Write-Verbose "Closing Last Safe: $opensafe"
        .\PACLI closesafe "SAFE=`"$opensafe`"" | Out-Null
    
        Remove-Variable -Name opensafe
    }
    
    Remove-Variable -Name AccountsToMigrate
    .\PACLI logoff;
    .\PACLI term;
    Write-Host 'Completed'
    
  4. Update the variable at the top of the script with the relevant values (<vaultaddress>, <vaultuser>, <vaultuserpassword>, <oldplatform PolicyID>, <newplatform PolicyID>)
  5. Execute the script.


Actions
  • Print
  • Copy Link

    https://knowledgebase.paloaltonetworks.com/KCSArticleDetail?id=kA1hj0000000nf5CAA&lang=en_US&refURL=http%3A%2F%2Fknowledgebase.paloaltonetworks.com%2FKCSArticleDetail