dbatools icon indicating copy to clipboard operation
dbatools copied to clipboard

Issues while passing Computer name parameter of type Dataplat.Dbatools.Parameter.DbaInstanceParameter[] using variable in update-dbainstance

Open Poojacheshmish opened this issue 1 year ago • 1 comments

Verified issue does not already exist?

No, I did not search

What error did you receive?

"Cannot convert value "DEDA1W9262,DEDA1W9261" to type "Dataplat.Dbatools.Parameter.DbaInstanceParameter". Error: "Failed to parse instance name: DEDA1W9262,DEDA1W9261"" At C:\Users\sadm-X265343\Desktop\Final Code.ps1:20 char:34

  • Update-DbaInstance -ComputerName $Serverslist -Credential $Creds -KB ...
  •                              ~~~~~~~~~~~~
    
    • CategoryInfo : InvalidData: (:) [Update-DbaInstance], ParameterB indingArgumentTransformationException
    • FullyQualifiedErrorId : ParameterArgumentTransformationError,Update-DbaIn stance

Steps to Reproduce

# provide your command(s) executed pertaining to dbatools
# please include variable values (redacted or fake if needed) for reference
``
$Serverslist=DXXXX1W9262,DXXXX1W9261
$creds= pscredential
$patch=KB5033663

Update-DbaInstance -ComputerName $Serverslist -Credential $Creds -KB $Patch -Download -Path "C:\Temp\SQLPatches"  -Confirm:$false -Restart


### Please confirm that you are running the most recent version of dbatools

Major  Minor  Build  Revision
-----  -----  -----  --------
2      1      14     -1  

### Other details or mentions

-computerName works fine if you are passing single computer name not with mutliple remote machines

### What PowerShell host was used when producing this error

Windows PowerShell ISE (powershell_ise.exe)

### PowerShell Host Version

$PSVersionTable

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

### SQL Server Edition and Build number

SQL Server - Product version: 15.0.4365.2, file version: 2019.150.4365.2

### .NET Framework Version

.NET Framework 4.8.4645.0

Poojacheshmish avatar May 08 '24 15:05 Poojacheshmish

$Serverslist=DXXXX1W9262,DXXXX1W9261 is incorrect PowerShell syntax.

If you use $Serverslist='DXXXX1W9262', 'DXXXX1W9261', the command should work fine, because $Serverlist is an array containing two strings. If you use $Serverslist='DXXXX1W9262,DXXXX1W9261', then this is only one string that is not parsable as an instance name.

andreasjordan avatar May 11 '24 12:05 andreasjordan

@andreasjordan that is certainly the problem, will close this. Thank you.

potatoqualitee avatar May 18 '24 05:05 potatoqualitee