有没有办法调用Backup-SqlDatabase cmdlet,但是它是否使用SQL Server凭据连接到SQL Server 2012?
我目前使用的命令是:
Backup-SqlDatabase -ServerInstance $serverName -Database $sqldbname -BackupFile "$($backupFolder)$($dbname)_db_$($addinionToName).bak"
Run Code Online (Sandbox Code Playgroud)
但这取决于正在调用它的用户,默认情况下,正在使用Windows身份验证.
我有一个用于备份数据库的 PowerShell 脚本。但今天它停止工作并出现下一个错误:
Backup-SqlDatabase : The term 'Backup-SqlDatabase' 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.
Run Code Online (Sandbox Code Playgroud)
我没有改变剧本。原因可能是什么?
更新:安装了 SqlServer 模块。现在我有下一个:
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
PS C:\Temp> import-module sqlserver -erroraction stop -verbose
VERBOSE: Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\sqlserver\21.0.17224\sqlserver.psd1'.
VERBOSE: Loading 'TypesToProcess' from path 'C:\Program
Files\WindowsPowerShell\Modules\sqlserver\21.0.17224\sqlprovider.types.ps1xml'.
VERBOSE: Loading …Run Code Online (Sandbox Code Playgroud)