gpt4 book ai didi

Azure 自动化 Powersell Runbook 失败 : 'Invoke-Sqlcmd' is not recognized as the name of a cmdlet

转载 作者:行者123 更新时间:2023-12-04 22:55:35 25 4
gpt4 key购买 nike

我已完成以下教程的所有步骤,以获得用于自动化索引和统计维护的操作手册:

https://blogs.msdn.microsoft.com/azuresqldbsupport/2018/01/15/automating-azure-sql-db-index-and-statistic-maintenance-using-azure-automation/

我能够顺利完成所有教程,但是当我执行 Runbook 时,它返回一个错误:

Invoke-Sqlcmd : The term 'Invoke-Sqlcmd' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:6 char:16
+ $SQLOutput = $(Invoke-Sqlcmd -ServerInstance $AzureSQLServerName -Use ...
+ ~~~~~~~~~~~~~
+ CategoryInfo: ObjectNotFound: (Invoke-Sqlcmd:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

我能做什么?我将 SQL Server 与 Azure 结合使用。具体来说,Azure SQL 数据库的定价/模型层为“S4 标准(200 DTU)”。

最佳答案

关注该博客,我重现了您的错误。

您可以部署sqlserver module通过此页面:

enter image description here

这是我的操作手册:

$AzureSQLServerName = "jasonsql"
$AzureSQLDatabaseName = "jasondatabase"

$AzureSQLServerName = $AzureSQLServerName + ".database.windows.net"
$Cred = Get-AutomationPSCredential -Name "SQLLogin"
$SQLOutput = $(Invoke-Sqlcmd -ServerInstance $AzureSQLServerName -Username $Cred.UserName -Password $Cred.GetNetworkCredential().Password -Database $AzureSQLDatabaseName -Query "SELECT * FROM INFORMATION_SCHEMA.TABLES " -QueryTimeout 65535 -ConnectionTimeout 60 -Verbose) 4>&1

Write-Output $SQLOutput

结果如下:

enter image description here

希望这有帮助。

关于Azure 自动化 Powersell Runbook 失败 : 'Invoke-Sqlcmd' is not recognized as the name of a cmdlet,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48992673/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com