Citrix Virtual Apps and Desktops 2402 SDK

Get-XDDatabaseSchema

Gets the SQL scripts used to create and manage the Database.

Syntax

Get-XDDatabaseSchema
   [-DatabaseName <String>]
   -DatabaseServer <String>
   -DataStore <DataStore>
   [-ScriptType <DatabaseScriptType>]
   -SiteName <String>
   [-AdminAddress <String>]
   [<CommonParameters>]
<!--NeedCopy-->

Description

Generates SQL scripts that can be given to a database administrator for execution. Scripts are written to standard output.

A script of type FullDatabase is used to manually create the Database with write access permissions for the Delivery Controller identified by AdminAddress. This script must be generated and executed for each datastore type supported by the Site.

Once the database administrator has executed all scripts of type FullDatabase, run New-XDSite to configure the databases for first use.

Examples

EXAMPLE 1

Gets the script for creating the Site Configuration Database and writes the content to the file “c:\script.sql”. This script may be executed on a database server “MyDBServer” for an existing and empty database with name “MySiteDB”.

Get-XDDatabaseSchema -SiteName MySiteServiceGroup -DataStore Site -DatabaseName MySiteDB -DatabaseServer MyDBServer -ScriptType FullDatabase > c:\script.sql
<!--NeedCopy-->

EXAMPLE 2

Gets the script used to write the access permissions for ‘MyNewController’ to the Configuration Logging Database. The contents of the script are written to the file “c:\script.sql”. This script may be executed on a database server “MyDBServer” for an existing database with name “MyLoggingDB”. The Controller can then only be added to the Site by running Add-XDController.

Get-XDDatabaseSchema -AdminAddress MyNewController -SiteName MySiteServiceGroup -DataStore Logging -DatabaseName MyLoggingDB -DatabaseServer MyDBServer -ScriptType AddController > c:\script.sql
<!--NeedCopy-->

EXAMPLE 3

Gets the script used to remove the access permissions for a Controller with SID ‘S-1-5-21-1234567890-123456789-123456789-1234’ from the Monitoring Database. The contents of the script are written to the file “c:\script.sql”. This script can be executed only after the Controller has been removed from the Site with Remove-XDController. It may be executed on a database server “MyDBServer” for an existing database with name “MyLoggingDB”.

Get-XDDatabaseSchema -SiteName MySiteServiceGroup -DataStore Monitor -DatabaseName MyMonitorDB -DatabaseServer MyDBServer -ScriptType RemoveController -ControllerToRemoveSid S-1-5-21-1234567890-123456789-123456789-1234 > c:\script.sql
<!--NeedCopy-->

EXAMPLE 4

Gets the script used to add a logon for ‘MyExistingController’ to the Site Configuration Database for the database mirror server “MyMirrorDBServer”. The contents of the script are written to the file “c:\script.sql”.

Get-XDDatabaseSchema -AdminAddress MyExistingController -SiteName MySiteServiceGroup -DataStore Site -DatabaseName MySiteDB -DatabaseServer MyMirrorDBServer -ScriptType AddDatabaseLogOn > c:\script.sql
<!--NeedCopy-->

Parameters

-DatabaseServer

The address of the SQL server on which the generated script will be run.

Type: String
Position: Named
Default value: None
Required: True
Accept pipeline input: False
Accept wildcard characters: True

-DataStore

The datastore type of the script to be generated. There is no default value. Valid values are:

  • Site

This corresponds to the Site Configuration Database.

  • Logging

This corresponds to the Configuration Logging Database.

  • Monitor

This corresponds to the Monitor Database.

Type: DataStore
Position: Named
Default value: None
Required: True
Accept pipeline input: False
Accept wildcard characters: False

-SiteName

The name of the Site for which the SQL script is to be generated.

Type: String
Position: Named
Default value: None
Required: True
Accept pipeline input: False
Accept wildcard characters: True

-DatabaseName

The name for the database of the selected datastore. There is a default name for each database. The default names are listed with their corresponding dataStore types as follows:

  • Site

The Site Configuration Database. The default name of this database is Citrix<SiteName>.

  • Logging

The Configuration Logging Database. The default name of this database is CitrixConfigLogging<SiteName>.

  • Monitor

The Monitoring Database. The default name of this database is CitrixMonitor<SiteName>.

Type: String
Position: Named
Default value: None
Required: False
Accept pipeline input: False
Accept wildcard characters: True

-ScriptType

The type of SQL script to be generated. By default, a script of type FullDatabase is generated. Valid types are:

  • AddController

This script is used to add a Controller specified by AdminAddress. It updates the specified database with all the access permissions needed by the Controller.

  • AddDatabaseLogOn

This script is used to add a logon for a Controller to the specified database server. It is used specifically for configuring SQL Server mirroring, in which the mirror database server must have appropriate logons created for all Controllers in the site.

  • FullDatabase

This script is used to create a database corresponding to the specified DataStore parameter. It also updates the database with all the access permissions needed for the Controller.

  • RemoveController

This script is used to remove a Controller specified by the ControllerToRemoveSid parameter. It removes the database access permissions previously required by the Controller.

Type: DatabaseScriptType
Position: Named
Default value: FullDatabase
Required: False
Accept pipeline input: False
Accept wildcard characters: False

-AdminAddress

Specifies the address of the Delivery Controller to which the PowerShell module will connect. This can be provided as a host name or an IP address.

Type: String
Position: Named
Default value: Localhost. Once a value is provided by any cmdlet, this value will become the default.
Required: False
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

Inputs

None

You cannot pipe input into this cmdlet.

Outputs

String

A string containing the content of the generated SQL script.

Notes

When the ScriptType is set to RemoveController, you must specify the dynamic parameter “ControllerToRemoveSid”. This specifies the SID of the Controller that is to be removed from the Site. The resultant database script removes the controller’s permissions to change the Database data.

If a script of type FullDatabase is generated for a configured Site, the resulting script adds database access permissions for all known Controllers to the database to be created.

If the cmdlet fails, the following error codes can result:

  • The datastore was not recognized.
  • The database server name could not be resolved.
Get-XDDatabaseSchema