Using the backup and restore scripts

If you want to use the sample backup and restore scripts to backup self-contained Centrify zones, you must modify the content of the scripts before executing them.

To run the sample backup script:

  1. Open the backup.ps1 file in a text editor.
  2. Modify the path to the zone you want to back up and the path to the backup file at the start of the sample script.

    # Input the zone DN you want to backup
    $zoneDn = "CN=Headquarters,CN=Zones,OU=Centrify Pubs,DC=pistolas,DC=org"
    $xmlPath = "C:\Program Files\Centrify\HQ-test.xml"
  3. Modify the confirmation message at the end of the script to display the path to the backup file.

    Write-Host "Backup to C:\Program Files\Centrify\HQ-test.xml is done."
  4. Save your changes with a new file name—for example, HQbackup.ps1—to keep the sample backup.ps1 script unchanged.
  5. Open the Centrify Access Module for PowerShell.

    Alternatively, you can use the default Windows PowerShell console. If you use open the default Windows PowerShell console, run the import-module with the path to the Access Module for PowerShell libraries. For example, if you installed the module in the default location, run the following command to import the Centrify Access Module for PowerShell:

    import-module “C:\Program Files\Centrify\PowerShell\Centrify.DirectControl.PowerShell.dll”
  6. Verify you have permission to execute scripts.

    Get-ExecutionPolicy

    In most cases, the permission to execute scripts is restricted. You can use the Set‑ExecutionPolicy to allow execution. For example:

    Set-ExecutionPolicy Unrestricted

    For more information about execution policies and the options available, use the get‑help function.

  7. Verify you are in the directory where the scripts are located.
  8. Execute the sample script.

    .\HQbackup.ps1

To restore a zone from a backup file:

  1. Open the restore.ps1 file in a text editor.
  2. Modify the path to the zone you want to restore and the path to the backup file at the start of the sample script.

    ## Input the zone container you want to create
    $newZoneContainer = "CN=Zones,OU=Centrify Pubs,DC=pistolas,DC=org
    ...
    $xmlPath = "C:\Program Files\Centrify\HQ-test.xml"
  3. Save your changes with a new file name—for example, HQrestore.ps1—to keep the sample restore.ps1 script unchanged.
  4. Open the Centrify Access Module for PowerShell.
  5. Execute the sample script.

    .\HQrestore.ps1