The return keyword is really just for syntactical use. If any object is called before the return keyword, they too will be return. So essentially you're returning a list of Objects, which is exactly what the error is telling you.
Let's take this for example. This code will return an array of $y values, but never an $x.
function return-test {
$x = 1
$y = 2
write-host $x # Console output only
$x | out-null # Goes to null
$x > $null # Goes to null
[void] $x # Goes to null
$y # is returned
return $y # is returned, but now the return value is an array.
}
So what you need to do is decide what you want to do with $db.CreateDate.DateTime
and $db.DatabaseOptions.RecoveryModel
. If you just want to display them on the console, then use write-host
like so...
function New-Database {
...
write-host $db.CreateDate.DateTime
write-host $db.DatabaseOptions.RecoveryModel
# You can use return if you prefer to see it.
# Either way, you want to return one value.
#return $db
$db
}