Sqlcmd command strips $ out of query variable
Have you tried defining $InstanceName as a string literal with single quotations?

PS C:\&gt; $GoodInstanceName = '$myInstanceName'
PS C:\&gt; "Hostname$GoodInstanceName"
Hostname$myInstanceName

PS C:\&gt; $BadInstanceName = "$myInstanceName"
PS C:\&gt; "Hostname$BadInstanceName"
Hostname


In Powershell, string literals that are defined with double-quotes will resolve variables.  However, if they are defined with single-quotes, they will not.  Since $myInstanceName resolved in the $BadInstanceName example but has never been defined, it will simply resolve to an empty string.

I suspect this (or something similar) is the problem since the error seems to do with your completed path string.