This is a function that I keep in my profile so I can call it in any of my scripts that will run from my profile. It makes it easier for me so it might for you.
function connect-sql ($arg)
if($arg -eq $null)
$server = Read-Host “enter instance name to connect to”
$server = $arg
$global:s = New-Object (‘Microsoft.SqlServer.Management.Smo.Server’) $server
This function allows you to make SMO connections to your instances very easily. You can pass it the instance name or it will ask you if you do not. Hope that helps