Windows Vista Forums
Vista Forums Home Join Vista Forums Webcasts Windows 7 Forum Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

sqlcmd and powershell and a failed login

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 05-09-2008   #1 (permalink)
SkipSailors
Guest


 

sqlcmd and powershell and a failed login

I am confused.

I have a command line that executes as expected in a CMD shell but doesn't
in a PowerSehll box. Specifically, the following fails:
& sqlcmd -E -S (local)\SQLExpress -d adatabase -i ascript.sql
while this suceeds in a DOS box
sqlcmd -E -S (local)\SQLExpress -d adatabase -i ascript.sql

The error is
Cannot open database "adatabase" requested by the login. The login
failed. Msg 18456, Level 14, State 1, Server localname\SQLExpress, login
failed for user 'domain\me'

Now, if I just
& sqlcmd -S (local)\SQLExpress
I get to an interactive rpompt and I can then "use" and execute DDL
statements. So I must be missing some part of the security setting for
PowerShell that are different from the DOS box, and I am wondering if y'all
could help me figure out what.

TIA

I know, the -E is redundant. I cd to the folder where th script lives. The
database exists. TCP for the database is enable, as is named pipes. The
current login is a user in the database mapping to the dbo schema.

--
I'm not sayin' anything, I'm just sayin'

My System SpecsSystem Spec
Old 05-09-2008   #2 (permalink)
Marco Shaw [MVP]
Guest


 

Re: sqlcmd and powershell and a failed login

Quote:

> I get to an interactive rpompt and I can then "use" and execute DDL
> statements. So I must be missing some part of the security setting for
> PowerShell that are different from the DOS box, and I am wondering if y'all
> could help me figure out what.
I was surprised also, but then wondered... Are you using Vista or 2008?
Might this have to do with whether you're running PowerShell with
Administrator priviledges?

Marco

--
Microsoft MVP - Windows PowerShell
http://www.microsoft.com/mvp

PowerGadgets MVP
http://www.powergadgets.com/mvp

Blog:
http://marcoshaw.blogspot.com
My System SpecsSystem Spec
Old 05-09-2008   #3 (permalink)
SkipSailors
Guest


 

Re: sqlcmd and powershell and a failed login


--
I''m not sayin'' anything, I''m just sayin''


"Marco Shaw [MVP]" wrote:
Quote:

>
Quote:

> > I get to an interactive rpompt and I can then "use" and execute DDL
> > statements. So I must be missing some part of the security setting for
> > PowerShell that are different from the DOS box, and I am wondering if y'all
> > could help me figure out what.
>
> I was surprised also, but then wondered... Are you using Vista or 2008?
> Might this have to do with whether you're running PowerShell with
> Administrator priviledges?
>
> Marco
>
> --
> Microsoft MVP - Windows PowerShell
> http://www.microsoft.com/mvp
>
> PowerGadgets MVP
> http://www.powergadgets.com/mvp
>
> Blog:
> http://marcoshaw.blogspot.com
>
XP SP2 is the OS. And the aco**** is root on the local box.
My System SpecsSystem Spec
Old 05-09-2008   #4 (permalink)
Marco Shaw [MVP]
Guest


 

Re: sqlcmd and powershell and a failed login

Quote:

> The error is
> Cannot open database "adatabase" requested by the login. The login
> failed. Msg 18456, Level 14, State 1, Server localname\SQLExpress, login
> failed for user 'domain\me'
>
> Now, if I just
> & sqlcmd -S (local)\SQLExpress
> I get to an interactive rpompt and I can then "use" and execute DDL
> statements. So I must be missing some part of the security setting for
> PowerShell that are different from the DOS box, and I am wondering if y'all
> could help me figure out what.
On XP SP2, this worked for me:
PSH> sqlcmd -E -S "(local)\sqlexpress" -d database_name

Marco

--
Microsoft MVP - Windows PowerShell
http://www.microsoft.com/mvp

PowerGadgets MVP
http://www.powergadgets.com/mvp

Blog:
http://marcoshaw.blogspot.com
My System SpecsSystem Spec
Old 05-09-2008   #5 (permalink)
SkipSailors
Guest


 

Re: sqlcmd and powershell and a failed login

>
Quote:

> On XP SP2, this worked for me:
> PSH> sqlcmd -E -S "(local)\sqlexpress" -d database_name
>
> Marco
You put quotes around the server name, but not around the database name.
Does that have any significance?
My System SpecsSystem Spec
Old 05-09-2008   #6 (permalink)
Marco Shaw [MVP]
Guest


 

Re: sqlcmd and powershell and a failed login

SkipSailors wrote:
Quote:
Quote:

>> On XP SP2, this worked for me:
>> PSH> sqlcmd -E -S "(local)\sqlexpress" -d database_name
>>
>> Marco
>
> You put quotes around the server name, but not around the database name.
> Does that have any significance?
I'm also using the v2 CTP2. Things might parse differently if you're
using v1... The above worked for me. My database name was a simple
string (no spaces or special characters).

Marco
My System SpecsSystem Spec
Old 05-09-2008   #7 (permalink)
SkipSailors
Guest


 

Re: sqlcmd and powershell and a failed login

Quote:

> I'm also using the v2 CTP2. Things might parse differently if you're
> using v1... The above worked for me. My database name was a simple
> string (no spaces or special characters).
>
> Marco
>
I just installed the CTP2 on my local machine and ran the script again. No
joy. My database name is also simple, only ASCII-type characters in the name
with no spaces or tabs or anything

My System SpecsSystem Spec
Old 05-09-2008   #8 (permalink)
Marco Shaw [MVP]
Guest


 

Re: sqlcmd and powershell and a failed login

SkipSailors wrote:
Quote:
Quote:

>> I'm also using the v2 CTP2. Things might parse differently if you're
>> using v1... The above worked for me. My database name was a simple
>> string (no spaces or special characters).
>>
>> Marco
>>
>
> I just installed the CTP2 on my local machine and ran the script again. No
> joy. My database name is also simple, only ASCII-type characters in the name
> with no spaces or tabs or anything
I'll think about it, but I'm not sure what the cause might be at this
point...

Marco
My System SpecsSystem Spec
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Login Completely Blocked w/User Profile Service Failed the Login THNKIT Vista account administration 10 07-15-2008 06:42 PM
Login registration has failed the profile cannot be loaded Steve Vista General 1 04-08-2008 01:09 PM
Login failed Bexy Vista mail 3 03-08-2008 03:03 PM
Always failed login at Startup vbclown Vista account administration 1 11-10-2007 04:23 PM
User Login Failed Mr_Lambie Vista account administration 2 07-27-2007 05:18 PM


Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51