Update-DbaServiceAccount with piped in Get-DbaService output from a named instance fails to update Engine
Verified issue does not already exist?
Yes
What error did you receive?
Cannot process argument transformation on parameter 'SqlInstance'. Cannot convert value
"COMPUTER09B.mydomain.com\MSSQL$INSTANCENAME09B" to type
"Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]". Error: "Cannot convert value
"COMPUTER09B.mydomain.com\MSSQL$INSTANCENAME09B" to type
"Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter". Error: "Failed to parse instance name:
COMPUTER09B.mydomain.com\MSSQL$INSTANCENAME09B. Computer Name: COMPUTER09B.mydomain.com,
Instance MSSQL$INSTANCENAME09B""
At C:\Program Files\WindowsPowerShell\Modules\dbatools\1.1.70\allcommands.ps1:93851 char:9
+ throw $records[0]
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], Exception
+ FullyQualifiedErrorId : dbatools_Update-DbaServiceAccount
Steps to Reproduce
Get-DbaService -ComputerName COMPUTER09B -Type Engine | Update-DbaServiceAccount -Username 'mydomain\gmsa09B$' -EnableException
Are you running the latest release?
Yes
Other details or mentions
In running this on a server with Agent and Engine. Agent worked but Engine fails to update. This is broken since version 1.1.47 I believe this issue relates to #8030. I suspect this section: https://github.com/dataplat/dbatools/blob/c817c4e80256dccaa17cd5d451196d3558772248/functions/Update-DbaServiceAccount.ps1#L226-L230
In the ServiceCollection input object coming from Get-DbaService, the ServiceName value for a named instance will be something like "MSSQL$InstanceName" Therefore, if using this value later in a SqlInstance parameter the "MSSQL$" portion should be removed. Based on the Error output, I believe this is where something is going wrong.
I have reverted to version 1.1.46 on the system where I needed to use this today, so I have a temporary workaround.
What PowerShell host was used when producing this error
Windows PowerShell (powershell.exe)
PowerShell Host Version
Name Value
PSVersion 5.1.14409.1018
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14409.1018
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
SQL Server Edition and Build number
Microsoft SQL Server 2019 (RTM-CU14) (KB5007182) - 15.0.4188.2 (X64) Nov 3 2021 19:19:51 Copyright (C) 2019 Microsoft Corporation Enterprise Edition: Core-based Licensing (64-bit) on Windows Server 2019 Standard 10.0
.NET Framework Version
.NET Framework 4.7.3890.0
Thanks for reporting this and thats for the analysis - that helps a lot. I will try to provide a fix for that today.