Powershell: create Windows event log

Create a NT eventlog for testing event monitor or rules:

Write-Eventlog -Logname ‘Application’ -Source ‘Hyperion EPMA DimensionServer’ -EventID 0 -EntryType Error -Message “This is a test of Gustavo Mendez (SCOM)”



More informationhttp://technet.microsoft.com/en-us/library/hh849847.aspx

To write an event to an event log, the event log must exist on the computer and the source must be registered for the event log.

The cmdlets that contain the EventLog noun (the EventLog cmdlets) work only on classic event logs. To get events from logs that use the Windows Event Log technology in Windows Vista and later versions of Windows, use Get-WinEvent.



Find the groups that belongs a Scom agent

# ——————————————————————————————————————–
# Name: Get-GroupsForOneObject.ps1
# Author: Gustavo Méndez, 23/08/2013
# Version: 1.0
# Description: Displays all groups that one Scom agent belongs
# Change value of variable $stringObject by the server name to find
# ——————————————————————————————————————

# Initialize hashtable array (index will be the group name)


# Declare object to find

$stringObject=”Object Name or Server Name”;

# Find and save the Scom object

$Class = get-monitoringclass -name “Microsoft.SystemCenter.Agent”;

$objectToFind = Get-MonitoringObject -monitoringclass:$Class | ? {$_.displayname -match $stringObject}

# If object is null exit

If (!($objectToFind))
write-host “It doesn’t exist or it could be for example a VMware virtual machine server discovered by Veeam MP without Scom agent”;


# Obtain groups

$mg = (Get-ManagementGroupConnection).ManagementGroup;

$groups = $mg.GetRootPartialMonitoringObjectGroups() | sort DisplayName;

# Find the object in each group

foreach ($group in $groups)

$groupMembers = $group.GetRelatedPartialMonitoringObjects([Microsoft.EnterpriseManagement.Common.TraversalDepth]::OneLevel);

# If group contain members…

if($groupMembers.Count -ne 0)


# Compare each member group with the object to find

foreach ($groupMember in $groupMembers)


if ($groupMember.displayname -match $objectToFind)


# Add group to array

$array.$objectToFind += (“$group, “);





$array.GetEnumerator() | Sort-Object Name | Out-GridView; # Print results in a new window;