I had some difficulties with this a few months ago, and I found that the only way to make it work was to include the instance name when specifying the server. For example:
$myServer = "SERVER\INSTANCENAME";
Specifying just the server would not work, even with TCP/IP enabled.