How do you update Powershell SQLChangeAutomation Module?

I'm running into a vexing problem trying to work through some experiments with the powershell commandlets.   

I'm getting the following error working with the nuget package from our build server (TFS 2015):

New-DatabaseReleaseArtifact : An unhandled error occurred: RedGate.SQLCompare.Engine.Registration.ReadFromSnapshot.UnsupportedSnapshotException: The database snapshot was saved by a newer version of SQL Compare

Looking at my list of installed modules, I've got 3.0.2.2482, and it looks like there's a new version out there for 3.0.2.2525 (or something similar).   I'm working my way through the steps, ensuring I have the latest version of nuget (2.8.5.208) and the latest version of PowerShellGet (1.6.7).   When I get to SqlChangeAutomation, I'm getting the following:


PS C:\temp> Update-Module -Name SqlChangeAutomation
Update-Module : Module 'SqlChangeAutomation' was not installed by using Install-Module, so it cannot 
be updated.
At line:1 char:1
+ Update-Module -Name SqlChangeAutomation
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (SqlChangeAutomation:String) [Write-Error], WriteError 
   Exception
    + FullyQualifiedErrorId : ModuleNotInstalledUsingInstallModuleCmdlet,Update-Module

I'm assuming this is because I've got SCA installed with my Visual Studio 2017, but there's no published update in visual studio that I can see.   How do I resolve this issue?
Tagged:

Best Answer

  • Mike UMike U Posts: 316 Gold 1
    Unfortunately PowerShell has a tendency of loading the old version of PowerShellGet by default, even if you've got a newer version installed. To be absolutely certain, you'll need to run the following:
    Import-Module PowerShellGet -MinimumVersion 1.6 -Force<br>Import-PackageProvider PowerShellGet -MinimumVersion 1.6 -Force<br><br>Install-Module SQLChangeAutomation
    I'm assuming you're doing this all on a development machine to test things out by the way. The various SQL Change Automation build/release extensions have their own auto-updating mechanism to download the latest version of SQL Change Automation from PowerShellGet, which does some more complicated things to make sure that it can work without admin permissions (if you're interested in the gory details, you can look in the extension directory for the file PowerShellGallery.ps1 to see what we do).

    Development Lead
    Redgate Software

Answers

Sign In or Register to comment.