Get-SqlServer issues


I'm new to SQLPSX, but in trying to follow an example on someones site:
Import-Module sqlmaint
$SQLServer = "localhost"
$SQLDBName = "work"
$SQLQuery = "SELECT * FROM dbo.server"

 $database = Get-SqlDatabase $sqlserver $SQLDBName
I get the error:
Exception calling "Contains" with "1" argument(s): "Failed to connect to server server='localhost';Trusted_Connection=true;multipleactiveresultsets=false."
At C:\Users\ZierdE1\Documents\WindowsPowerShell\Modules\sqlserver\SQLServer.psm1:164 char:37
  • { if ($server.Databases.Contains <<<< ("$dbname") -and $server.Databases[$dbname].IsAccessible)
    • CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    • FullyQualifiedErrorId : DotNetMethodException
I've tracked this down to the Get-SqlServer function. The current function performs the following:
$server = new-object ("Microsoft.SqlServer.Management.Smo.Server") $con
I believe the issue is with the $con variable. $ con is set in the Get-SQLConnection function, where it does:
$con = new-object ("Microsoft.SqlServer.Management.Common.ServerConnection") $sqlserver
The code works if I change the Get-SqlServer function code from:
$server = new-object ("Microsoft.SqlServer.Management.Smo.Server") $con
$server = new-object ("Microsoft.SqlServer.Management.Smo.Server") $sqlserver
So if I give it a server name, instead of a Connection.

according to get-host|Select-Object version I am running version

I'm including a screen shot of both the failure and success in a simplified query...sorry that it looks distorted.

file attachments