Skip to content

Commit

Permalink
Merge branch 'release/1.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Steffen committed Aug 18, 2022
2 parents 3768d6a + 1e3fadf commit 729d1ed
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 26 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.1.0] - 2022-08-18

### Added

- Default parameter set for `Connect-Instance`.

## [1.0.0] - 2022-08-18

### Added
Expand Down
22 changes: 11 additions & 11 deletions docs/Connect-SmoInstance.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ schema: 2.0.0

## SYNTAX

### Properties_IntegratedSecurity (Default)
```
Connect-SmoInstance [-DataSource] <String> [[-InitialCatalog] <String>] [-AccessToken <String>]
[<CommonParameters>]
```

### SqlClient
```
Connect-SmoInstance -Connection <SqlConnection> [<CommonParameters>]
Expand All @@ -22,13 +28,7 @@ Connect-SmoInstance -Connection <SqlConnection> [<CommonParameters>]
Connect-SmoInstance [-ConnectionString] <String> [<CommonParameters>]
```

### Properties_IntegratedSecurity
```
Connect-SmoInstance [-DataSource] <String> [[-InitialCatalog] <String>] [-AccessToken <String>]
[<CommonParameters>]
```

### Properties_SQLServerAuthentication
### Properties_Credential
```
Connect-SmoInstance [-DataSource] <String> [[-InitialCatalog] <String>] [-UserId] <String>
[-Password] <SecureString> [<CommonParameters>]
Expand Down Expand Up @@ -98,7 +98,7 @@ Accept wildcard characters: False
```yaml
Type: String
Parameter Sets: Properties_IntegratedSecurity, Properties_SQLServerAuthentication
Parameter Sets: Properties_IntegratedSecurity, Properties_Credential
Aliases: Server, ServerName, ServerInstance

Required: True
Expand All @@ -113,7 +113,7 @@ Accept wildcard characters: False
```yaml
Type: String
Parameter Sets: Properties_IntegratedSecurity, Properties_SQLServerAuthentication
Parameter Sets: Properties_IntegratedSecurity, Properties_Credential
Aliases: Database, DatabaseName

Required: False
Expand All @@ -128,7 +128,7 @@ Accept wildcard characters: False
```yaml
Type: SecureString
Parameter Sets: Properties_SQLServerAuthentication
Parameter Sets: Properties_Credential
Aliases:

Required: True
Expand All @@ -143,7 +143,7 @@ Accept wildcard characters: False
```yaml
Type: String
Parameter Sets: Properties_SQLServerAuthentication
Parameter Sets: Properties_Credential
Aliases:

Required: True
Expand Down
35 changes: 21 additions & 14 deletions src/PsSmo/ConnectInstanceCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,30 @@

namespace PsSmo
{
[Cmdlet(VerbsCommunications.Connect, "Instance")]
[Cmdlet(VerbsCommunications.Connect, "Instance", DefaultParameterSetName = PARAMETERSET_PROPERTIES_INTEGRATED)]
[OutputType(typeof(Server))]
public class ConnectInstanceCommand : PSCmdlet
{
#region ParameterSets
private const string PARAMETERSET_CONNECTION_STRING = "ConnectionString";
private const string PARAMETERSET_PROPERTIES_INTEGRATED = "Properties_IntegratedSecurity";
private const string PARAMETERSET_PROPERTIES_CREDENTIAL = "Properties_Credential";
private const string PARAMETERSET_SQL_CLIENT = "SqlClient";
#endregion

internal static Server Instance { get; set; }

#region Parameters

[Parameter(
Mandatory = true,
ValueFromPipeline = true,
ParameterSetName = "SqlClient"
ParameterSetName = PARAMETERSET_SQL_CLIENT
)]
public SqlConnection Connection { get; set; }

[Parameter(
ParameterSetName = "ConnectionString",
ParameterSetName = PARAMETERSET_CONNECTION_STRING,
Position = 0,
Mandatory = true,
ValueFromPipeline = true,
Expand All @@ -34,13 +41,13 @@ public class ConnectInstanceCommand : PSCmdlet
public string ConnectionString { get; set; }

[Parameter(
ParameterSetName = "Properties_IntegratedSecurity",
ParameterSetName = PARAMETERSET_PROPERTIES_INTEGRATED,
Position = 0,
Mandatory = true,
ValueFromPipelineByPropertyName = true
)]
[Parameter(
ParameterSetName = "Properties_SQLServerAuthentication",
ParameterSetName = PARAMETERSET_PROPERTIES_CREDENTIAL,
Position = 0,
Mandatory = true,
ValueFromPipelineByPropertyName = true
Expand All @@ -50,13 +57,13 @@ public class ConnectInstanceCommand : PSCmdlet
public string DataSource { get; set; }

[Parameter(
ParameterSetName = "Properties_IntegratedSecurity",
ParameterSetName = PARAMETERSET_PROPERTIES_INTEGRATED,
Position = 1,
Mandatory = false,
ValueFromPipelineByPropertyName = true
)]
[Parameter(
ParameterSetName = "Properties_SQLServerAuthentication",
ParameterSetName = PARAMETERSET_PROPERTIES_CREDENTIAL,
Position = 1,
Mandatory = false,
ValueFromPipelineByPropertyName = true
Expand All @@ -66,14 +73,14 @@ public class ConnectInstanceCommand : PSCmdlet
public string InitialCatalog { get; set; }

[Parameter(
ParameterSetName = "Properties_IntegratedSecurity",
ParameterSetName = PARAMETERSET_PROPERTIES_INTEGRATED,
ValueFromPipelineByPropertyName = true
)]
[ValidateNotNullOrEmpty()]
public string AccessToken { get; set; }

[Parameter(
ParameterSetName = "Properties_SQLServerAuthentication",
ParameterSetName = PARAMETERSET_PROPERTIES_CREDENTIAL,
Position = 1,
Mandatory = true,
ValueFromPipeline = true,
Expand All @@ -82,7 +89,7 @@ public class ConnectInstanceCommand : PSCmdlet
public string UserId { get; set; }

[Parameter(
ParameterSetName = "Properties_SQLServerAuthentication",
ParameterSetName = PARAMETERSET_PROPERTIES_CREDENTIAL,
Position = 1,
Mandatory = true,
ValueFromPipeline = true,
Expand All @@ -98,7 +105,7 @@ protected override void ProcessRecord()

switch (ParameterSetName)
{
case "SqlClient":
case PARAMETERSET_SQL_CLIENT:
WriteVerbose("Connect by existing connection");
Instance = new Server(
serverConnection: new ServerConnection(
Expand All @@ -107,7 +114,7 @@ protected override void ProcessRecord()
);
break;

case "ConnectionString":
case PARAMETERSET_CONNECTION_STRING:
{
WriteVerbose("Connect by connection string");
SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder();
Expand All @@ -121,7 +128,7 @@ protected override void ProcessRecord()
break;
}

case "Properties_IntegratedSecurity":
case PARAMETERSET_PROPERTIES_INTEGRATED:
{
WriteVerbose("Connect by Integrated Security");
SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder();
Expand All @@ -148,7 +155,7 @@ protected override void ProcessRecord()
break;
}

case "Properties_SQLServerAuthentication":
case PARAMETERSET_PROPERTIES_CREDENTIAL:
{
WriteVerbose("Connect by SQL Server Authentication");
SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder();
Expand Down
2 changes: 1 addition & 1 deletion src/PsSmo/PsSmo.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'PsSmo.dll'

# Version number of this module.
ModuleVersion = '1.0.0'
ModuleVersion = '1.1.0'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down

0 comments on commit 729d1ed

Please sign in to comment.