Samples/Event Consumers/ConfigMgr/ConfigMgr - System Resource Created.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
# EXAMPLE for PowerEvents PowerShell module available on http://powerevents.codeplex.com
#
# Author: Trevor Sullivan
# Date: 05/24/11
# Brief: This example shows how to use PowerEvents to create a WMI event consumer that calls a script in response to
# a new System Center Configuration Manager system resource being created.

$VBcode = @"
set fso = CreateObject("Scripting.FileSystemObject")
set LogFile = fso.OpenTextFile("c:\SCCM.log", 8, true)
call LogFile.WriteLine(Date() & " " & Time() & ": New ConfigMgr system resource created!")
"@

New-WmiEventConsumer -Name ConfigMgrSystemResourceCreated -ConsumerType Script -ScriptText $VBcode