Skip to content

Hyphen in Windows name breaks dbatools #4090

@Carsten3000

Description

@Carsten3000

An Windows name that ends with an hyphen breaks dbatools.

Steps to Reproduce

PS > Test-DbaConnection XX-XXX-SQL2017-\CL_DW
Test-DbaConnection : Cannot process argument transformation on parameter 'SqlInstance'. Cannot convert value
"XX-XXX-SQL2017-\CL_DW" to type "Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]". Error: "Cannot convert
value "XX-XXX-SQL2017-\CL_DW" to type "Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter". Error: "Failed to
parse instance name: XX-XXX-SQL2017-\CL_DW. Computer Name: XX-XXX-SQL2017-, Instance CL_DW""
At line:1 char:20
+ Test-DbaConnection XX-XXX-SQL2017-\CL_DW
+                    ~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Test-DbaConnection], ParameterBindingArgumentTransformationException
    + FullyQualifiedErrorId : ParameterArgumentTransformationError,Test-DbaConnection

PS > Test-DbaConnection XX.XXX.250.30\CL_DW
ComputerName         : XX.XXX.250.30
InstanceName         : CL_DW
SqlInstance          : XX.XXX.250.30\CL_DW
....

Expected Behavior

Using the hostname and ip work equally.

Actual Behavior

Only calling the server by his ip works.

This forced me to do a dbamigration with the ip, even with the ip i got 2 errors:

Configuration Value             AllowPolybaseExport               Successful
Test-ElevationRequirement : Cannot process argument transformation on parameter 'ComputerName'. Cannot convert value
"XX-XXX-SQL2017-" to type "Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter". Error: "Failed to parse instance
name: XX-XXX-SQL2017-"
At C:\Program Files\WindowsPowerShell\Modules\dbatools\0.9.428\allcommands.ps1:5364 char:57
+ ...  $null = Test-ElevationRequirement -ComputerName $Source.ComputerName
+                                                      ~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Test-ElevationRequirement], ParameterBindingArgumentTransformationExce
   ption
    + FullyQualifiedErrorId : ParameterArgumentTransformationError,Test-ElevationRequirement

Mail Configuration              Server Configuration              Successful
Mail Server                     mx1.xxx.net                   Successful
Test-ElevationRequirement : Cannot process argument transformation on parameter 'ComputerName'. Cannot convert value
"CL-KNZ-SQL2017-" to type "Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter". Error: "Failed to parse instance
name: CL-KNZ-SQL2017-"
At C:\Program Files\WindowsPowerShell\Modules\dbatools\0.9.428\allcommands.ps1:8819 char:57
+ ...  $null = Test-ElevationRequirement -ComputerName $Source.ComputerName
+                                                      ~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Test-ElevationRequirement], ParameterBindingArgumentTransformationExce
   ption
    + FullyQualifiedErrorId : ParameterArgumentTransformationError,Test-ElevationRequirement

Environmental data

  • PowerShell:
    PSVersion 5.1.14393.2485
    PSEdition Desktop
    PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
    BuildVersion 10.0.14393.2485
    CLRVersion 4.0.30319.42000
    WSManStackVersion 3.0
    PSRemotingProtocolVersion 2.3
    SerializationVersion 1.1.0.1

  • SQL Server: Microsoft SQL Server 2017 (RTM-GDR) (KB4057122) - 14.0.2000.63 (X64) Dec 22 2017 16:01:23 Copyright (C) 2017 Microsoft Corporation Standard Edition (64-bit) on Windows Server 2016 Datacenter 10.0 (Build 14393: ) (Hypervisor)

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions