En voulant ajouter des événements dans l’Event Viewer pour faire des essais avec SCOM, au moment d’exécuter mon script, j’ai eu le message suivant :
PS C:\Windows\system32> C:\Users\Administrator\Desktop\Generate_Log.ps1
Write-eventlog : The source 'Test_SCOM' is not registered in log 'Application'. (It is registered in log 'Operations Manager'.) " The Source and Log properties must be matched, or you may set Log to the empty string, and it will automatically be matched to the Source property.
At C:\Users\Administrator\Desktop\Generate_Log.ps1:259 char:21
+ Write-eventlog -logname "Application" -ComputerName "." -Sou ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Write-EventLog], Exception
+ FullyQualifiedErrorId : The source 'Test_SCOM' is not registered in log 'Application'. (It is registered in log 'Operations Manager'.) " The Source and Log properties must be matched, or you may set Log to the empty string, and it will automatically be matched to the Source property.,Microsoft.PowerShell.Commands.WriteEventLogCommand
Ce message apparait si par exemple, vous avez créé auparavant un évenement avec le même nom source, dans un Log Name différent. Pour régler ce problème, il suffit de supprimer la clé de registre qui correspond au nom de votre log source (dans mon cas Test_SCOM) dans :
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Operations Manager
Le problème a maintenant disparu quand le script est execute de nouveau.