1

I am trying to connect to an sql14 server via sqlps powershell module, but keep getting this error: Cannot find path 'SQLSERVER:\SQL\SERVER\DEFAULT' because it does not exist'.

The server does exist and is responsive. I tried connecting to it with pssession, and that did work, but then trying again with sqlps module- failed.

Am I missing something else? other sql servers worked fine.

EDIT:

I found the solution! I changed the $debugpreference to 'continue'- and got a message: SQL Server PowerShell provider error: Could not connect to server. [Failed to connect to server . --> The target principal name is incorrect. Cannot generate SSPI context.]

with this message I managed to find out the spn for the sqlserver belonged to the computer account and not the user account running the services. I fixed that issue and managed to connect.

2
  • Can you provide the command line you're using to connect? Helping on nothing but an error message seems difficult ;) Commented Sep 13, 2016 at 15:34
  • I just enter "cd SQLSERVER:\SQL\SERVER\DEFAULT". Commented Sep 14, 2016 at 4:22

2 Answers 2

2

I found the solution! I changed the $debugpreference to 'continue'- and got a message: SQL Server PowerShell provider error: Could not connect to server. [Failed to connect to server . --> The target principal name is incorrect. Cannot generate SSPI context.]

with this message I managed to find out the spn for the sqlserver belonged to the computer account and not the user account running the services. I fixed that issue and managed to connect.

Sign up to request clarification or add additional context in comments.

Comments

0

Your path is incorrect. The "SERVER" part needs to be replaced with the name of your server.

SQLSERVER:\SQL\[server name]\DEFAULT

In PowerShell, the SQLSERVER:\SQL is known as a PowerShell drive, which is a logical representation of a data store in the file system or elsewhere. PowerShell drives provide a consistent way to navigate and interact with different data stores using familiar file system navigation commands.

PS C:\Windows\system32> cd SQLSERVER:\SQL\
PS SQLSERVER:\SQL\> dir

MachineName
-----------
SQLSRV01


PS SQLSERVER:\SQL\> cd SQLSRV01
PS SQLSERVER:\SQL\SQLSRV01> dir

Instance Name
-------------
DEFAULT


PS SQLSERVER:\SQL\SQLSRV01> cd DEFAULT
PS SQLSERVER:\SQL\SQLSRV01\DEFAULT> Enable-SqlAlwaysOn

In the context of SQL Server PowerShell, SQLSERVER:\SQL is a PowerShell drive specifically designed to interact with SQL Server instances. It's analogous to navigating directories in a file system, but instead of navigating directories and files, you're navigating SQL Server instances and databases.

Once you navigate to the appropriate SQL Server instance using this PowerShell drive, you can then execute commands and access properties specific to that instance using PowerShell cmdlets provided by SQL Server PowerShell module.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.