For some reasons, like, having a bunch of procedures that include Unix/Linux servers into SCOM, you might get the 'An Item With The Same Key Has Already Been Added' error when you go to Administration - Unix/Linux Agents.
That means that you've duplicate unix/linux servers in your SCOM installation.
The only way to solve this is to find the duplicate entry, and delete them both.
To do that, you can't use the Get-SCXAgent, this will output unique values only - the only way to solve this is going to your OpsDB execute a querry (bellow), and foreach value you get, you need to run the 'get-scxagent "duplicate_value" | Remove-ScxAgent' cmdlet.
So, first things first.
The query :
DECLARE @ClassName NVARCHAR(256)
DECLARE @CManagedTypeId UNIQUEIDENTIFIER
SET @ClassName = 'Microsoft.Unix.OperatingSystem'
SET @CManagedTypeId = (
SELECT ManagedTypeId
FROM ManagedType
WHERE TypeName = @ClassName )
SELECT
[ManagedEntityGenericView].[Id],
[ManagedEntityGenericView].[Name],
[ManagedEntityGenericView].[Path],
[ManagedEntityGenericView].[FullName],
[ManagedEntityGenericView].[LastModified],
[ManagedEntityGenericView].[TypedManagedEntityId],
NULL AS SourceEntityId
FROM
dbo.ManagedEntityGenericView
INNER JOIN (
SELECT DISTINCT [BaseManagedEntityId]
FROM dbo.[TypedManagedEntity] TME WITH(NOLOCK)
JOIN [dbo].[DerivedManagedTypes] DT ON DT.[DerivedTypeId] = TME.[ManagedTypeId]
WHERE
DT.[BaseTypeId] = @CManagedTypeId
AND TME.IsDeleted = 0 )
AS ManagedTypeIdForManagedEntitiesByManagedTypeAndDerived
ON ManagedTypeIdForManagedEntitiesByManagedTypeAndDerived.[BaseManagedEntityId] = [Id]
WHERE
[IsDeleted] = 0 AND
[TypedMonitoringObjectIsDeleted] = 0 AND
[ManagedEntityGenericView].[Path] IN (
SELECT [BaseManagedEntity].[Path]
FROM [BaseManagedEntity]
GROUP BY [BaseManagedEntity].[Path]
HAVING COUNT([BaseManagedEntity].[Path]) > 1
)
GROUP BY [ManagedEntityGenericView].[Id],
[ManagedEntityGenericView].[Name],
[ManagedEntityGenericView].[Path],
[ManagedEntityGenericView].[FullName],
[ManagedEntityGenericView].[LastModified],
[ManagedEntityGenericView].[TypedManagedEntityId]
HAVING COUNT([ManagedEntityGenericView].[Path]) > 1
Now that you've the duplicate values to delete, just open a powershell prompt and run the follow cmdlet foreach duplicate value you've.
get-scxagent "Your_Server" | Remove-ScxAgent
And, your problem is solved.
Cheers,
https://scomgustavo.wordpress.com/2013/09/06/scom-2012-error-in-unixlinux-computers-an-item-with-the-same-key-has-already-been-added/
ReplyDeletethis works perfect for me.
(Yet, Another Blog About ...) System Center: Opsmgr (Scom) - Solve The "An Item With The Same Key Has Already Been Added" Error >>>>> Download Now
ReplyDelete>>>>> Download Full
(Yet, Another Blog About ...) System Center: Opsmgr (Scom) - Solve The "An Item With The Same Key Has Already Been Added" Error >>>>> Download LINK
>>>>> Download Now
(Yet, Another Blog About ...) System Center: Opsmgr (Scom) - Solve The "An Item With The Same Key Has Already Been Added" Error >>>>> Download Full
>>>>> Download LINK