Invoke-sqlcmd with a databse name with brackets

Fellow Powershellers and dbas.

I was trying to run a invoke-sql cmd where the database name has been formatted with brackets. I know some that put brackets around the db name as standard wroting t-sql. I happend to have that coming in for the databse name and invoke-sql does not like it.
In the below you see hte vairable $MaindbName.

If that has “MyCompanyDatabase” coming in it connects as expected. but if it comes in a [MyCompanyDatabase], login fails.

Is this not permitted in invoke-sqlcmd?

thanks Mark

$results = Invoke-Sqlcmd -ServerInstance $MainSQLServerNameConnection -Database $Maindbname -Query $IN_SQLQuery -As DataTables -QueryTimeout 600 -