I have created the following variable $cred:
$User = "sa"
$PWord = ConvertTo-SecureString -String "teste" -AsPlainText -Force
$cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User, $PWord
Then, I open a connection with dbatools script.
$server1 = Connect-DbaInstance `
-SqlInstance '192.168.0.61\TESTE2017' `
-SqlCredential $cred`
-TrustServerCertificate;
But powershell still prompt asking for a credential:
Why?

There's great information in the comments; let me try to summarize:
PowerShell commands (pipelines) situationally require explicit line continuation using a line-ending
`(the so-called backtick, which is PowerShell's general escape character), notably when spreading distinct arguments across multiple lines.By contrast,
`is not needed if a command's line is syntactically incomplete, because PowerShell then automatically looks for the command's completion on the next line; e.g.:If and when you do need
`for line-continuation, the following strict rules apply:The line-ending
`must NOT be followed by any additional characters - not even whitespace.The line-ending
`must NOT be directly attached to the last argument to the line - make sure that it is preceded by a space.[1]If you do accidentally directly attach
`to a (syntactically incomplete) last argument, it is (potentially) continued on the next line, including the newline, IF that newline starts with a non-whitespace character.In your case, this meant that verbatim
-TrustServerCertificatewas appended to the stringified value of variable$cred, which resulted in a string value such as the following ($cred- uselessly - stringified to its type name):-SqlCredentialparameter, resulting in the symptom you saw.[1] Technically, a space is not needed if the preceding argument is itself syntactically complete, but not only is it safe to always use a space, it also provides visual clarity.