安装 SQL Server PowerShellInstall SQL Server PowerShell

适用于:Applies to: 是SQL ServerSQL Server(所有支持的版本)yesSQL ServerSQL Server (all supported versions) - 仅限 Windows 适用于:Applies to: 是SQL ServerSQL Server(所有支持的版本)yesSQL ServerSQL Server (all supported versions) - Windows only

SQL ServerSQL Server 安装程序会自动配置 PowerShell 组件。Setup automatically configures PowerShell components.

您通过使用 SQL ServerSQL Server 安装程序安装为 Windows PowerShell 提供 SQL ServerSQL Server 支持的软件。You install the software that provides SQL ServerSQL Server support for Windows PowerShell by using SQL ServerSQL Server Setup. 选择要求 SQL ServerSQL Server PowerShell 支持的任何功能时,安装程序将安装下列 SQL ServerSQL Server PowerShell 组件:When you select any SQL ServerSQL Server features that require PowerShell support, Setup installs the following SQL ServerSQL Server PowerShell components:

  • SQL ServerSQL Server PowerShell 管理单元。这些管理单元是 dll 文件,可用来实现两种类型的 SQL ServerSQL ServerWindows PowerShell 支持:The SQL ServerSQL Server PowerShell snap-ins. The snap-ins are dll files that implement two types of Windows PowerShell support for SQL ServerSQL Server:

    • 一组 SQL ServerSQL Server cmdlet。A set of SQL ServerSQL Server cmdlets. Cmdlet 是用来实现特定操作的命令。Cmdlets are commands that implement a specific action. 例如, Invoke-Sqlcmd 可用于运行 Transact-SQLTransact-SQL 或 XQuery 脚本,而这些脚本也可使用 sqlcmd 实用工具运行, Invoke-PolicyEvaluation 用于报告 SQL ServerSQL Server 对象是否符合基于策略的管理策略。For example, Invoke-Sqlcmd runs a Transact-SQLTransact-SQL or XQuery script that can also be run by using the sqlcmd utility, and Invoke-PolicyEvaluation reports whether SQL ServerSQL Server objects comply with policy-based management policies.

    • 一个 SQL ServerSQL Server 提供程序。A SQL ServerSQL Server provider. 通过该提供程序,可以使用类似于文件系统路径的路径,在 SQL ServerSQL Server 对象的层次结构中导航。The provider lets you navigate the hierarchy of SQL ServerSQL Server objects using a path similar to a file system path. 每个对象都与 SQL ServerSQL Server 管理对象模型中的一个类关联。Each object is associated with a class from the SQL ServerSQL Server Management object models. 您可以使用该类的方法和属性来针对对象执行工作。You can use the methods and properties of the class to perform work on the objects. 例如,如果通过 cd 切换到路径中的某个数据库对象,则可以使用 Microsoft.SqlServer.Managment.SMO.Database 类的方法和属性来管理该数据库。For example, if you cd to a databases object in a path, you can use the methods and properties of the Microsoft.SqlServer.Managment.SMO.Database class to manage the database.

  • sqlps 模块,该模块将导入到 Windows PowerShell 会话中以便加载 SQL ServerSQL Server 管理单元。The sqlps module that is imported into Windows PowerShell sessions to load the SQL ServerSQL Server snap-ins.

  • SQL Server Management StudioSQL Server Management Studio 支持从对象资源管理器树启动 Windows PowerShell 会话。supports starting Windows PowerShell sessions from the Object Explorer tree. SQL ServerSQL Server 代理支持 Windows PowerShell 作业步骤。Agent supports Windows PowerShell job steps.

Windows Server 2012 及更高版本和 Windows 8 及更高版本已安装和配置了 PowerShell。Windows Server 2012 and later and Windows 8 and later come with PowerShell installed and configured. 有关安装 Windows PowerShell 的信息,请参阅安装 Windows PowerShellFor information about installing Windows PowerShell see Installing Windows PowerShell.

有关详细信息,请参阅:For more information, see: