Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Import-DbaXESessionTemplate] Name cannot be specified with multiple files or templates because the Session will already exist. #4923

Closed
3 of 4 tasks
ijeb opened this issue Jan 9, 2019 · 0 comments · Fixed by #4917

Comments

@ijeb
Copy link

ijeb commented Jan 9, 2019

Before submitting a bug report:

  • Ensure you are able to reproduce it on the latest released version (we release often)
  • Verified this bug is not already reported in an issue
  • Verified errors are not related to permissions
  • Can reproduce in a clean PowerShell session (clean = powershell -NoProfile)

If two or more templates are imported, they can't get the same name. In this case the warning should be shown.

    if (($Path.Count -gt 1 -or $Template.Count -gt 1) -and (Test-Bound -ParameterName Template)) {
        Stop-Function -Message "Name cannot be specified with multiple files or templates because the Session will already exist."
    }

So the second part should be Test-Bound -ParameterName Name

The function continues anyway when the warning is shown. For me it makes more sense if the function just stops after the warning instead of just doing the job partly.

Steps to Reproduce

Case 1:
Import-DbaXESessionTemplate -SqlInstance . -Template 'Database Health 2016 and Above','Activity Tracking'

Case 2:
Import-DbaXESessionTemplate -SqlInstance . -Template 'Database Health 2016 and Above','Activity Tracking' -Name test

## Expected Behavior

The first case should not show the warning. The second case should show the warning:
"Name cannot be specified with multiple files or templates because the Session will already exist."

## Actual Behavior

The first case shows the warning and the second case not.

## Environmental data

<!-- Provide output of the following two commands -->

 - PowerShell: 

Name                           Value                                                                                                                                                                                                                             
----                           -----                                                                                                                                                                                                                             
PSVersion                      5.1.14393.2636                                                                                                                                                                                                                    
PSEdition                      Desktop                                                                                                                                                                                                                           
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                                                                                                                           
BuildVersion                   10.0.14393.2636                                                                                                                                                                                                                   
CLRVersion                     4.0.30319.42000                                                                                                                                                                                                                   
WSManStackVersion              3.0                                                                                                                                                                                                                               
PSRemotingProtocolVersion      2.3                                                                                                                                                                                                                               
SerializationVersion           1.1.0.1   

 - - SQL Server:

Microsoft SQL Server vNext (CTP2.0) - 15.0.1000.34 (X64)   Sep 18 2018 10:18:13   Copyright (C) 2018 Microsoft Corporation  Developer Edition (64-bit) on Windows Server 2016 Datacenter 10.0 <X64> (Build 14393: ) (Hypervisor) 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant