Cmdlets to provide and manage SQL servers for tests.
Creates a LocalDB instance and returns its connection parameters. Requires PsSqlLocalDb and an installed LocalDB utility.
New-SqlTestLocalInstance [[-Name] <String>] [[-Version] <Version>] [-Connected]
[-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]
Uses [SqlLocalDB Utility](https://docs.microsoft.com/en-us/sql/tools/sqllocaldb-utility?view=sql-server-ver15) to get info about the available local db.
$instance = New-SqlTestLocalInstance
Creates a temporary LocalDB instance. The selected SQL Server version depends on the versions installed locally.
Captured output (temporary instance name redacted; the installed version may vary):
Name : test-<redacted> Version : 15.0.4382.1 DataSource : (LocalDb)\test-<redacted> ConnectTimeout : 30 ConnectionString : Data Source=(LocalDb)\test-<redacted>;Connect Timeout=30;Integrated Security=True IsLocalDb : True PS> $instance | Remove-SqlTestLocalInstance Removes the LocalDB instance created by this example.
Specifies the name of the instance to create.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: ( New-DatabaseName )
Accept pipeline input: False
Accept wildcard characters: False
Specifies the version of the sql server.
Type: Version
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Specifies whether a SqlClient connection should be created.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
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
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
Type: ActionPreference
Parameter Sets: (All)
Aliases: proga
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
https://abbgrade.github.io/PsSqlTestServer/docs/New-SqlTestLocalInstance.html