August 24, 2016 at 4:45 pm
Example
$instanceName ="Host001\Server1,14002"
$AppName = "$($ENV:computername.ToString())_$(($MyInvocation.MyCommand).Path)"
$conn = new-object Microsoft.SqlServer.Management.Common.ServerConnection
$conn.ServerInstance = $instanceName
$conn.ApplicationName = $AppName
$conn.LoginSecure = $FALSE
currently I logged in to domain as Company\poweruser1
I want to connect to sql server as different domain user
$credential = Get-Credential -- at pop credential dialog box I enter user as Company\DBA and password as 123456
$loginName = $credential.UserName
$conn.Login = $loginName
$conn.Password = $credential.Password
$srv = new-object Microsoft.SqlServer.Management.Smo.Server($conn)
Write-Host $srv.Information.Version
as result connection was not established
What am I missing?
August 25, 2016 at 12:01 am
Is it integrated authentication?
If so then my understanding is that you need something like what is found here: http://poshcode.org/1867
Gaz
-- Stop your grinnin' and drop your linen...they're everywhere!!!
August 25, 2016 at 12:06 am
August 25, 2016 at 12:12 am
Basically, I think that you have been attempting to connect using the method for SQL Server logins whereas you want to connect as a domain account.
Gaz
-- Stop your grinnin' and drop your linen...they're everywhere!!!
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply