I have Powershell installed both in my server and development pc. In my dev machine apparently have a most recent version of PowerShell installed or some its components of SQL Server 'sqlps'. My current problem is that I can't list databases as I do in my dev machine like this:
PS SQLSERVER:\> ls SQLSERVER:\\SQL\server\instance\Databases\
And I get the following:
Get-ChildItem : No se encuentra la ruta de acceso 'SQLSERVER:\SQL\serverr2\serverr2\Databases' porque no existe.
En línea: 1 Carácter: 4
+ dir <<<< SQLSERVER:\SQL\server\instance\Databases
+ CategoryInfo : ObjectNotFound: (SQLSERVER:\SQL\server\instance\Databases:String) [Get-ChildItem], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
Obviously I have no way to get Child-Items like the Stored Procedures, Views, etc.
However, I'm able to list the installed instances, and also workaround this issue by listing databases with this:
DIR SQLSERVER:\\SQL\serverr2 | SELECT Databases -ExpandProperty Databases | SELECT Name,Owner,Urn
But still need to get another objects like stored procedures, views, functions,etc.
This is the info provided by the Get-Host cmdlet
Name : ConsoleHost
Version : 2.0
InstanceId : c1976472-19c0-439e-a4f6-debe59a18616
UI : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture : es-MX
CurrentUICulture : es-ES
PrivateData : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
IsRunspacePushed : False
Runspace : System.Management.Automation.Runspaces.LocalRunspace
and the @@version of SQL Server is Microsoft SQL Server 2008 (SP1) - 10.0.2531.0 (X64)
Edit: According to $PSVersionTable.PSVersion
in my server I have installed PowerShell 2.0. Also I found that I'm unable to Import-Module sqlps
but for some reason I'm capable to dir
as I already described (with the current problems obviously).
Import-Module
" mean? Do you get an error message? If so, which one? What doesGet-Module
show?