0

I have a CI build process that's been working great for months. Despite having no changes, it suddenly broke and now consistently fails with this error:

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

The process provisions a new VM every time so I'm guessing it has something to do with Microsoft updates but I can't tell what. Thus far, the only way I've been able to fix it is to log in through RDP to the newly provisioned VM before the CI process starts.

I tried adding Import-Module SQLPS to the build script and got an even weirder error message

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

I tried Install-Module SQLPS and got

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

So I added

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

But am now getting a new error:

"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."

I feel like I'm running in circles. Is this a Microsoft update or something? Can anyone tell me how to fix my AzureRM module which seems to me to be breaking my SQLPS module somehow?

sirdank
  • 3,351
  • 3
  • 25
  • 58
  • Have you tried uninstalling and reinstalling them module yet? – Persistent13 Sep 01 '17 at 16:27
  • @Persistent13 I did try that but it supposedly couldn't find the module. I edited my question. – sirdank Sep 01 '17 at 19:45
  • This isn't a direct answer to the question, but if you want to install a SQL Server module you'll need to run `Install-Module -Name SqlServer` as SQLPS is not available on the PowerShell Gallery. However, it may still get you want you want. Be sure to remove SQLPS first otherwise you'll run into conflicts. – Persistent13 Sep 01 '17 at 20:20
  • @Persistent13 Thanks for the suggestions but after implementing them I am receiving the same 'Could not find file ...Commands.Profile.format.ps1xml' error that I was when importing SQLPS. – sirdank Sep 05 '17 at 13:25

1 Answers1

0

I can't figure it out. I rewrote it to use sqlcmd and BACKUP DATABASE.

sirdank
  • 3,351
  • 3
  • 25
  • 58