diff --git a/CHANGELOG.md b/CHANGELOG.md index c3c6448..dca833b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.2.0] - 2023-08-24 + +### Changed + +- Verbose script execution prints the filepath. + ## [1.1.0] - 2022-08-18 ### Added diff --git a/src/PsSmo/InvokeCommandCommand.cs b/src/PsSmo/InvokeCommandCommand.cs index 93a5bce..6da3ed5 100644 --- a/src/PsSmo/InvokeCommandCommand.cs +++ b/src/PsSmo/InvokeCommandCommand.cs @@ -45,7 +45,7 @@ protected override void ProcessRecord() break; case "File": - WriteVerbose("Execute SQL script from file."); + WriteVerbose($"Execute SQL script from file '{ InputFile.FullName }'."); Text = File.ReadAllText(InputFile.FullName); break; @@ -54,14 +54,19 @@ protected override void ProcessRecord() } try { - Instance.ConnectionContext.ExecuteNonQuery(sqlCommand: processSqlCmdText(Text, processVariables(Variables))); - } catch (Exception ex) + Instance.ConnectionContext.ExecuteNonQuery(sqlCommand: ProcessSqlCmdText(Text, ProcessVariables(Variables))); + } + catch (PipelineStoppedException) + { + throw; + } + catch (Exception ex) { WriteError(new ErrorRecord(ex, ex.GetType().Name, ErrorCategory.NotSpecified, Text)); } } - private Dictionary processVariables(Hashtable variables) + private static Dictionary ProcessVariables(Hashtable variables) { var variableDictionary = new Dictionary(); @@ -76,12 +81,9 @@ private Dictionary processVariables(Hashtable variables) return variableDictionary; } - private string processSqlCmdText(string text, Dictionary variables) + private string ProcessSqlCmdText(string text, Dictionary variables) { - if (variables == null) - { - variables = new Dictionary(); - } + variables ??= new Dictionary(); var result = new List(); var variableRegex = new Regex(@"\$\((\w*)\)"); diff --git a/src/PsSmo/PsSmo.psd1 b/src/PsSmo/PsSmo.psd1 index 23e1132..72ff742 100644 --- a/src/PsSmo/PsSmo.psd1 +++ b/src/PsSmo/PsSmo.psd1 @@ -12,7 +12,7 @@ RootModule = 'PsSmo.dll' # Version number of this module. -ModuleVersion = '1.1.0' +ModuleVersion = '1.2.0' # Supported PSEditions # CompatiblePSEditions = @()