Test-AzPostgreSqlFlexibleServerConnect

Test out the connection to the database server

Syntax

Test-AzPostgreSqlFlexibleServerConnect
    -Name <String>
    -ResourceGroupName <String>
    [-DatabaseName <String>]
    -AdministratorLoginPassword <SecureString>
    [-AdministratorUserName <String>]
    [-DefaultProfile <PSObject>]
    [<CommonParameters>]
Test-AzPostgreSqlFlexibleServerConnect
    -Name <String>
    -ResourceGroupName <String>
    [-DatabaseName <String>]
    -QueryText <String>
    -AdministratorLoginPassword <SecureString>
    [-AdministratorUserName <String>]
    [-DefaultProfile <PSObject>]
    [<CommonParameters>]
Test-AzPostgreSqlFlexibleServerConnect
    [-DatabaseName <String>]
    -QueryText <String>
    -AdministratorLoginPassword <SecureString>
    [-AdministratorUserName <String>]
    -InputObject <IPostgreSqlIdentity>
    [-DefaultProfile <PSObject>]
    [<CommonParameters>]
Test-AzPostgreSqlFlexibleServerConnect
    [-DatabaseName <String>]
    -AdministratorLoginPassword <SecureString>
    [-AdministratorUserName <String>]
    -InputObject <IPostgreSqlIdentity>
    [-DefaultProfile <PSObject>]
    [<CommonParameters>]

Description

Test out the connection to the database server

Examples

Example 1: Test connection by name

$password = ConvertTo-SecureString -String "****" -AsPlainText -Force
Test-AzPostgreSqlFlexibleServerConnect -ResourceGroupName PowershellPostgreSqlTest -Name postgresql-test -AdministratorLoginPassword $password

The connection testing to postgresql-test.database.azure.com was successful!

Test connection by the resource group and the server name

Example 2: Test connection by identity

$password = ConvertTo-SecureString -String "****" -AsPlainText -Force
Get-AzPostgreSqlFlexibleServer -ResourceGroupName PowershellPostgreSqlTest -ServerName postgresql-test | Test-AzPostgreSqlFlexibleServerConnect -AdministratorLoginPassword $password

The connection testing to postgresql-test.database.azure.com was successful!

Test connection by the identity

Example 3: Test query by name

$password = ConvertTo-SecureString -String "****" -AsPlainText -Force
Test-AzPostgreSqlFlexibleServerConnect -ResourceGroupName PowershellPostgreSqlTest -Name postgresql-test -AdministratorLoginPassword $password -QueryText "SELECT * FROM test"

col
-----
1
2
3

Test a query by the resource group and the server name

Example 4: Test connection by identity

Get-AzPostgreSqlFlexibleServer -ResourceGroupName PowershellPostgreSqlTest -ServerName postgresql-test | Test-AzPostgreSqlFlexibleServerConnect -QueryText "SELECT * FROM test" -AdministratorLoginPassword $password

col
-----
1
2
3

Test a query by the identity

Parameters

-AdministratorLoginPassword

The password of the administrator. Minimum 8 characters and maximum 128 characters. Password must contain characters from three of the following categories: English uppercase letters, English lowercase letters, numbers, and non-alphanumeric characters.

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

-AdministratorUserName

Administrator username for the server. Once set, it cannot be changed.

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

-DatabaseName

The database name to connect.

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

-DefaultProfile

The credentials, account, tenant, and subscription used for communication with Azure.

Type:PSObject
Aliases:AzureRMContext, AzureCredential
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-InputObject

The server to connect. To construct, see NOTES section for INPUTOBJECT properties and create a hash table.

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

-Name

The name of the server to connect.

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

-QueryText

The query for the database to test

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

-ResourceGroupName

The name of the resource group that contains the resource, You can obtain this value from the Azure Resource Manager API or the portal.

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

Inputs

IPostgreSqlIdentity

Outputs

String