Test-SQLDatabaseExist
SYNOPSIS
Test if a SQL Server database exists on a specified server instance.
SYNTAX
Test-SQLDatabaseExist [-ServerInstance] <String> [-Database] <String> [-WhatIf] [-Confirm] [<CommonParameters>]
DESCRIPTION
This function checks if a SQL Server database exists on a specified server instance. It first verifies the availability of the server and the SQL instance, and then checks for the existence of the database.
EXAMPLES
EXAMPLE 1
Checks if the "TestDB" database exists on the "SQLInstance1" server.
EXAMPLE 2
Checks if the "ProdDB" database exists on the "SQLInstance2" server.
EXAMPLE 3
Verifies the existence of the "FinanceDB" database on the "SQLInstance3" server.
PARAMETERS
-ServerInstance
The name of the SQL Server instance to check.
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
-Database
The name of the database to verify.
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 2
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
-WhatIf
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Confirm
Prompts you for confirmation before running the cmdlet.
Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf
Required: False
Position: Named
Default value: None
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.