【问题标题】:The term 'Get-SqlErrorLog' is not recognized as the name of a cmdlet [Powershell] [SQL Server]术语“Get-SqlErrorLog”未被识别为 cmdlet [Powershell] [SQL Server] 的名称
【发布时间】:2020-02-25 05:16:29
【问题描述】:

我今天早些时候安装了 SQLServer 工具,并成功运行了 Get-SQLErrorLog 命令。然后我关闭 PowerShell 并去吃午饭。当我回来并重新启动 PowerShell 时,尝试运行完全相同的 Get-SQLErrorLog 给出:

Get-SqlErrorLog : 术语“Get-SqlErrorLog”未被识别为 cmdlet 的名称...

当我检查时,我看到:

Get-Module -ListAvailable -Name SQL*

    Directory: C:\Program Files\WindowsPowerShell\Modules

ModuleType Version    Name                                ExportedCommands                                                                                 
---------- -------    ----                                ----------------                                                                                 
Script     21.1.18218 SqlServer                           {Add-RoleMember, Add-SqlAvailabilityDatabase, Add-SqlAvailabilityGroupListenerStaticIp, Add-Sq...


    Directory: D:\Program Files (x86)\Microsoft SQL Server\130\Tools\PowerShell\Modules


ModuleType Version    Name                                ExportedCommands                                                                                 
---------- -------    ----                                ----------------                                                                                 
Manifest   1.0        SQLPS                               {Backup-SqlDatabase, Save-SqlMigrationReport, Add-SqlAvailabilityDatabase, Add-SqlAvailability...

谁能解释如何让我今天早些时候调用的函数再次工作?

【问题讨论】:

    标签: sql-server powershell


    【解决方案1】:

    运行Import-Module SqlServer,默认不会导入模块。

    如果你想默认导入模块,那么在终端输入$profile,找出文件的位置。然后打开(或创建,如果没有)该文件并在文件中输入Import-Module SqlServer 并保存。以后的任何会话都将加载该模块。

    【讨论】:

    • 我运行了“Import-Module SqlServer”,它没有返回任何错误,但似乎也没有做任何事情。 “Get-SqlErrorLog”继续失败并出现同样的错误。
    • 哇。我刚刚关闭并重新打开 PowerShell,现在 Get-SQLErrorLog 命令正在运行。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-27
    • 2012-06-22
    • 2020-06-12
    • 2019-10-12
    • 2017-12-11
    相关资源
    最近更新 更多