The following checks that you have values for each of the four variables:
if(($Instance) -and ($uname) -and ($pwd) -and ($newpwd))
{
$srv = new-object ('Microsoft.SqlServer.Management.Smo.Server') $Instance
#This sets the sql authentication
$srv.ConnectionContext.LoginSecure=$false;
#This sets the login name
$srv.ConnectionContext.set_Login($uname);
#This sets the password
$srv.ConnectionContext.set_Password($pwd)
}
else
{
# Handle missing value(s) condition.
}
Gaz
-- Stop your grinnin' and drop your linen...they're everywhere!!!