尽管安装了SQL Server,但未安装SQL Server PowerShell管理单元

时间:2023-01-26 21:57:14

I am using SQL Server 2012 SP1 developer edition. Lately I had a need to use SQL Server snapin but PowerShell claims not to have one. I made a research on the internet but I didn't find any working solution. Is there any way I can add it to PowerShell?

我正在使用SQL Server 2012 SP1开发人员版。最近我需要使用SQL Server管理单元,但PowerShell声称没有。我在互联网上做了一个研究,但我找不到任何有效的解决方案。有什么办法可以将它添加到PowerShell吗?

get-pssnapin -registered output:

get-pssnapin -registered输出:

Name : CommonSnapIn          PSVersion : 2.0 Description : Common SnapIn
Name : ConfigurationSnapIn   PSVersion : 2.0 Description : Configuration SnapIn
Name : DefinitionSnapIn      PSVersion : 2.0 Description : Definition SnapIn
Name : DynoPortalSnapIn      PSVersion : 2.0 Description : DynoPortal SnapIn
Name : FoldersSnapIn         PSVersion : 2.0 Description : Folders SnapIn
Name : JournalSnapIn         PSVersion : 2.0 Description : Journal SnapIn
Name : MembershipSnapIn      PSVersion : 2.0 Description : Membership SnapIn
Name : MetadataSnapIn        PSVersion : 2.0 Description : Metadata SnapIn
Name : NotificationSnapIn    PSVersion : 2.0 Description : Notification SnapIn
Name : PersistenceSnapIn     PSVersion : 2.0 Description : Foundation Persistence SnapIn
Name : ReportingSnapIn       PSVersion : 2.0 Description : Reporting SnapIn

add-PSSnapin sqlservercmdletsnapin100 output:

add-PSSnapin sqlservercmdletsnapin100输出:

PS C:\Users\CRDM and Secure 3> add-PSSnapin sqlservercmdletsnapin100
add-PSSnapin : The Windows PowerShell snap-in 'sqlservercmdletsnapin100' is not installed on this computer.    
At line:1 char:1  
+ add-PSSnapin sqlservercmdletsnapin100  
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
+ CategoryInfo          : InvalidArgument: (sqlservercmdletsnapin100:String) [Add-PSSnapin], PSArgumentException  
+ FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.AddPSSnapinCommand

1 个解决方案

#1


6  

In SQL Server 2012 the PowerShell functionality delivered by the product came in the form of a PowerShell module, so therefore you no longer need to work with the snapins.

在SQL Server 2012中,产品提供的PowerShell功能以PowerShell模块的形式提供,因此您不再需要使用管理单元。

To consume the SQL Server PowerShell module, you simply need to do this:

要使用SQL Server PowerShell模块,您只需执行以下操作:

Import-Module "sqlps"

Or if you are using PowerShell v3+ then you just need to reference a member of that module and it'll be automatically loaded in.

或者,如果您使用的是PowerShell v3 +,那么您只需要引用该模块的一个成员,它就会被自动加载。

#1


6  

In SQL Server 2012 the PowerShell functionality delivered by the product came in the form of a PowerShell module, so therefore you no longer need to work with the snapins.

在SQL Server 2012中,产品提供的PowerShell功能以PowerShell模块的形式提供,因此您不再需要使用管理单元。

To consume the SQL Server PowerShell module, you simply need to do this:

要使用SQL Server PowerShell模块,您只需执行以下操作:

Import-Module "sqlps"

Or if you are using PowerShell v3+ then you just need to reference a member of that module and it'll be automatically loaded in.

或者,如果您使用的是PowerShell v3 +,那么您只需要引用该模块的一个成员,它就会被自动加载。