2017-09-01 40 views
0

我有一個CI構建過程,它一直工作了好幾個月。雖然沒有變化,但突然闖進現在一直失敗,此錯誤:SQLPS/AzureRm.Profile模塊停止在Azure VM映像上工作

The 'Backup-SqlDatabase' command was found in the module 'SQLPS', but the module could not be loaded. For more information, run 'Import-Module SQLPS'.

每次處理規定一個新的虛擬機,所以我猜它是與微軟更新,但我不能告訴什麼。到目前爲止,我能夠解決它的唯一方法是在CI進程啓動之前通過RDP登錄到新調配的VM。

我嘗試添加Import-Module SQLPS到構建腳本,並得到了一個更加古怪的錯誤消息

Could not find file 'Microsoft.Azure.Commands.Profile.format.ps1xml'

我試圖Install-Module SQLPS並獲得

No match was found for the specified search criteria and module name 'SQLPS'.

所以我添加

$modules = (Get-Module -Name "AzureRM" -Verbose) 
$modules | Uninstall-Module -Force -Verbose 
Install-Module AzureRM -Verbose -Force 
Import-Module SQLPS 

,但我現在得到一個新的錯誤:

"The process cannot access the file 'C:\Program Files\WindowsPowerShell\Modules\AzureRM.profile\3.3.1\Hyak.Common.dll' because it is being used by another process."

我覺得我在圈子裏跑。這是微軟更新還是什麼?任何人都可以告訴我如何解決我的AzureRM模塊,這似乎是以某種方式破壞我的SQLPS模塊?

+0

您是否嘗試卸載並重新安裝它們模塊呢? – Persistent13

+0

@ Persistent13我確實嘗試過,但它應該找不到該模塊。我編輯了我的問題。 – sirdank

+0

這不是對問題的直接回答,但如果您想安裝SQL Server模塊,則需要運行'Install-Module -Name SqlServer',因爲SQLPS在PowerShell庫上不可用。但是,它可能仍然會讓你想要你想要的。一定要先刪除SQLPS,否則會遇到衝突。 – Persistent13

回答

0

我找不出來。我重寫了它使用sqlcmd和BACKUP DATABASE