Categories
HOW TO Microsoft PowerShell

HOW TO uninstall older versions of a PowerShell module installed

When using Windows PowerShell ISE it’s possible to import a PowerShell module, open the Command tool panel (from the menu Add-ons -> Command) and clicking Refresh, then have a list of the commands available.

It’s annoying that sometimes the same command appears multiple times, as the result of an installed PowerShell module that you updated.

Today’s example is from NavContainerHelper PowerShell module, searching in my pc for one of its commands I had multiple entries for the same command, as shown in the following picture:

Solution:
Run Windows PowerShell ISE as Administrator.
Copy and paste the following PowerShell script that retrieves the latest version of the desired module and then recursively uninstalls the previous versions installed.
Interesting to note, you can use the -WhatIf parameter at the end to simulate and preview the changes without doing them (remember to remove -WhatIf parameter when you want to apply the changes and to set the $ModuleName to the desired PowerShell module).

$ModuleName = 'navcontainerhelper';
$Latest = Get-InstalledModule $ModuleName; 
Get-InstalledModule $ModuleName -AllVersions | ? {$_.Version -ne $Latest.Version} | Uninstall-Module -WhatIf

To see the command list updated you need to restart Windows PowerShell ISE.

Did my HOW TO help you? Leave a reply.

Categories
Microsoft SQL Server

Cannot resolve the collation conflict between “SQL_Latin1_General_CP1_CI_AS” and “Latin1_General_100_CI_AS”

Cannot resolve the collation conflict between “SQL_Latin1_General_CP1_CI_AS” and “Latin1_General_100_CI_AS” in the equal to operation.

in Italian

Impossibile risolvere il conflitto tra le regole di confronto “SQL_Latin1_General_CP1_CI_AS” e “Latin1_General_100_CI_AS” nell’operazione equal to.

Cannot resolve the collation conflict between…, SELECT command example

[sourcecode lang=”SQL”]
SELECT * FROM YourTableName1 One INNER JOIN YourTableName2 Two on One.YourColumnName = Two.OffendingColumn
[/sourcecode]

Cause:
You have two tables with different collation in the columns

Solution 1:

Use COLLATE Left or Right side of comparison in your SELECT command, for example:

[sourcecode lang=”SQL”]
SELECT * FROM YourTableName1 One INNER JOIN YourTableName2 Two on One.YourColumnName = Two.OffendingColumn COLLATE SQL_Latin1_General_CP1_CI_AS
[/sourcecode]

Solution 2:
Change collation of your OffendingColumn in one of your tables so you’ll have the same collation in for successive comparison
[sourcecode lang=”SQL”]
ALTER TABLE YourTableName
ALTER COLUMN OffendingColumn
VARCHAR(100) COLLATE Latin1_General_CI_AS NOT NULL
[/sourcecode]

Did my solution solve your problem? Leave a reply.