Working with sample scripts

The Audit Module for PowerShell includes some sample scripts that you can use to do database rotation; rotating a database involves creating a new audit store database and making the new database the active database for the installation. You can copy and modify the sample scripts to use the code directly in your environment or study the syntax used in the script to serve as an example for writing your own custom scripts.

  • db_rotation.ps1

    This PowerShell script demonstrates how to use the following cmdlets to do database rotation:

    • New-CdaDatabase
    • Set-CdaDatabase
    • Detach-CdaDatabase
  • db_rotation_sql_script.ps1

    This PowerShell script demonstrates how to do database rotation using the SQL scripts and PowerShell cmdlets.

  • SetupDatabase.sql, SetupServer.sql

    You can modify the file path settings in these SQL scripts to create a new audit store database using the New-CdaDatabase cmdlet with the DatabaseScriptFile and ServerScriptFile parameters. This case is useful if you want to create a new audit store database with a customized database file folder path, database log file folder path, or database full-text catalog root path.

    If you want to use these SQL scripts and you also want to customize the StoredProcedureAccount, IsAwsRds, and IntegrityCheckEnabled settings, you also need to customize the settings in the SQL scripts instead of using the StoredProcedureAccount, IsAwsRds, and IntegrityCheckEnabled parameters. These three parameters can't be used along with the DatabaseScriptFile and ServerScriptFile parameters.

To run the sample script:

  1. Open the Centrify Audit Module for PowerShell.
  2. 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.

  3. Verify you are in the directory where the db_rotation.ps1 script is located.

  4. Execute the sample script.