This posting is provided "AS IS" with no warranties.
Monday, May 18, 2015
System Center Operations Manager Customer Survey
Wednesday, November 27, 2013
Florian Aguettaz IT Blog: [System Center] Full review of all System Center product ( #SystemCenter )

This posting is provided "AS IS" with no warranties.
Monday, July 1, 2013
[Orchestrator] Integrating Cluster Aware Updating with Operations Manager Maintenance Mode – Pre and Post Update Scripts ( #SCOM #Orchestrator )
This posting is provided "AS IS" with no warranties.
[System Center Suite] Download and test system center suite 1012 R2 Preview (#SystemCenter #SCOM #DPM #Orchestrator #SCSM #VMM #SCCM #OpsMgr)
- System
Center 2012 R2 Configuration Manager
- System
Center 2012 R2 App Controller
- System Center 2012 R2 Data Protection Manager
- System Center 2012 R2 Operations Manager
- System
Center 2012 R2 Orchestrator
- System
Center 2012 R2 Service Manager
- System Center 2012 R2 Virtual Machine Manager
- System Center 2012 R2 App Controller Preview
- System Center 2012 R2 Virtual Machine Manager Preview
- System Center 2012 R2 Data Protection Manager Preview
- System Center 2012 R2 Operations Manager Preview
- System Center 2012 R2 Orchestrator Preview
- System Center 2012 R2 Service Manager Preview
- System Center 2012 R2 Configuration Manager Preview
This posting is provided "AS IS" with no warranties.
Thursday, April 4, 2013
[OpsMgr 2007 R2] Powershell script to export all product knowledge for rule and monitor for a specific MP
With no access to SCOM console, I didn't find an easy way to do it and I also decided to proceed with a powershell script.
Here are the command line I've written to export all product knowledge for rules and monitors for a specific MP. Create a PS1 file named ExportKnowledgeArticleFromAMP.ps1 and copy paste the command line from this post and go down and click download to get the PS1 file.
Usage a this script needs 2 parameters : MP name and Path to create files.
Example:
.\ExportKnowledgeArticleFromAMP.ps1 "Microsoft.Windows.Server.PrintServer.2012" "C:\Temp"
- param([string]$MPName, [string]$Path)
- # Script to export all product knowledge for rule and monitor for a specified MP
- # usage : .\ExportKnowledgeArticleFromAMP.ps1 "Microsoft.Windows.Server.PrintServer.2012" "C:\Temp"
- function MamlToHTML($MAMLText)
- {
- $HTMLText = "";
- $HTMLText = $MAMLText -replace('xmlns:maml="http://schemas.microsoft.com/maml/2004/10"');
- $HTMLText = $HTMLText -replace("maml:para","p");
- $HTMLText = $HTMLText -replace("maml:");
- $HTMLText = $HTMLText -replace("</section>");
- $HTMLText = $HTMLText -replace("<section>");
- $HTMLText = $HTMLText -replace("<section >");
- $HTMLText = $HTMLText -replace("<title>","<h2>");
- $HTMLText = $HTMLText -replace("</title>","</h2>");
- $HTMLText = $HTMLText -replace("<listitem>","<li>");
- $HTMLText = $HTMLText -replace("</listitem>","</li>");
- $HTMLText = "<html><body>" + $HTMLText + "</body></html>";
- $HTMLText;
- }
- # Mainline
- # Clear the screen.
- cls;
- # Get US Culture information.
- $ciUS = [System.Globalization.CultureInfo]'en-US';
- # Retrieve the Management Pack.
- $mps = get-managementpack
- $mp = $mps | ? { $_.Name -eq $MPName}
- $FolderName = $MPName + " - " + $mp.version
- # Create Folder
- New-Item -ItemType directory -Path $Path\$FolderName
- # Retrieve the Management Pack rules and monitors.
- $rules = $mp.getrules()
- $monitors = $mp.getmonitors()
- cls
- # Retrieve the knowledge Article for rules.
- $i = 1
- $j = 1
- foreach ($rule in $rules) {
- $article = $rule.GetKnowledgeArticle($ciUS);
- if ($article -ne $Null)
- {
- if ($article.MamlContent -ne $Null)
- {
- $article_text = $article.MamlContent;
- $article_text = MamlToHTML($article_text);
- }
- write-host "Outputing HTML...";
- if ($rule.DisplayName -ne "")
- {
- $RuleName = "Rule - " + [string]$i + " - " + [string]$rule.DisplayName
- }
- else
- {
- $RuleName = "Rule - " + [string]$i + " - " + [string]$rule.Name
- }
- # < > : " / \ | ? * removal
- $RuleName
- $RuleName = $RuleName.replace('<','lower than')
- $RuleName = $RuleName.replace('>','Greater than')
- $RuleName = $RuleName.replace('/','')
- $RuleName = $RuleName.replace('|','')
- $RuleName = $RuleName.replace('\','')
- $RuleName = $RuleName.replace('!','')
- $RuleName = $RuleName.replace('?','')
- $RuleName = $RuleName.replace('*','')
- $RuleName = $RuleName.replace(':','')
- $RuleName = $RuleName.replace(';','')
- $ExportFile = $Path + "\" + $FolderName + "\" + $RuleName + ".htm";
- $article_text.tostring() | out-file $ExportFile
- $i = $i + 1
- }
- }
- # Retrieve the knowledge Article for monitors.
- foreach ($monitor in $monitors) {
- $article = $monitor.GetKnowledgeArticle($ciUS);
- if ($article -ne $Null)
- {
- if ($article.MamlContent -ne $Null)
- {
- $article_text = $article.MamlContent;
- $article_text = MamlToHTML($article_text);
- }
- write-host "Outputing HTML...";
- if ($monitor.DisplayName -ne "")
- {
- $MonitorName = "Monitor - " + [string]$j + " - " + [string]$monitor.DisplayName
- }
- else
- {
- $MonitorName = "Monitor - " + [string]$j + " - " + [string]$monitor.Name
- }
- # < > : " / \ | ? * removal
- $MonitorName
- $MonitorName = $MonitorName.replace('<','lower than')
- $MonitorName = $MonitorName.replace('>','Greater than')
- $MonitorName = $MonitorName.replace('/','')
- $MonitorName = $MonitorName.replace('|','')
- $MonitorName = $MonitorName.replace('\','')
- $MonitorName = $MonitorName.replace('!','')
- $MonitorName = $MonitorName.replace('?','')
- $MonitorName = $MonitorName.replace('*','')
- $MonitorName = $MonitorName.replace(':','')
- $MonitorName = $MonitorName.replace(';','')
- $ExportFile = $Path + "\" + $FolderName + "\" + $MonitorName + ".htm";
- $ExportFile
- $article_text.tostring() | out-file $ExportFile
- $j = $j + 1
- }
- }
- The script sometimes return errors on some monitors or rules - I guess the conversion to HTML is failing - but in that case, the impact is that the HTML file is not created for that rule/monitor.
- The script can be easily adapted of courses to run on OpsMgr 2012.
This posting is provided "AS IS" with no warranties.
Thursday, January 31, 2013
[OpsMgr 2012][Powershell] Get Alerts for all specified SCOM MP using powershell in Operations Manager 2012
- $mp = Get-SCOMManagementPack -name 'MPName'
- # Criteria : All alerts, raw and processed descriptions.
- # Output to : File (c:\temp\output\Alerts-all.csv)
- # Fields Selected: Lots.
- # Output Format : CSV
- # Notes : Need more work on this.
- $alerts_csv = "C:\MPName.csv";
- write-host "Exporting all alerts to csv: ",$alerts_csv;
- Get-SCOMAlert | select-object @{Name = '%'; expression ={$_.MonitoringObjectDisplayName}},Severity, Name, ResolutionState, RepeatCount,@{Name = 'Instances'; expression ={$_.RepeatCount+1}},@{Name = 'Created'; expression =
- {$_.TimeRaised.ToLocalTime()}},@{Name = 'Description (Processed)';Expression = {$_.Description -replace "`n"," " -replace " "," "}},MonitoringObjectFullName, IsMonitorAlert,Id,MonitoringRuleId,MonitoringClassId,Description | sort Name | export-csv $alerts_csv -noTypeInformation;
This posting is provided "AS IS" with no warranties.
Monday, October 8, 2012
[SCOM 2007] Authoring Management Pack - Create a VBS discovery with a debugging functionnality - PART III
This posting is provided "AS IS" with no warranties.
Monday, March 12, 2012
Microsoft Tech Days 2012 - Webcats (Video in French)
This posting is provided "AS IS" with no warranties.
Thursday, February 16, 2012
[Authoring MP] MPBPA analysis tool always report "Alerts should have name and description defined"
- when you open a rule, switch to configuration and check what is missing in the alert section.
- If it's not there, check display name and description for the alert.
A best practice should be to have a base MP contains only the ENU strings.
This posting is provided "AS IS" with no warranties.
Wednesday, January 18, 2012
Don't Miss MMS 2012 !
![]() |
| http://www.mms-2012.com/ |
MMS cuts through the marketing noise so you can learn the latest desktop and device management, datacenter and cloud technologies to help you solve today’s challenges. From keynotes to sessions to hands-on labs, certification opportunities, and face-to-face access to Microsoft and industry experts, MMS provides a “can’t-miss” opportunity to be among the first to learn about new technologies.
Why You Won’t Want to Miss It |
Intensive week of technical training
You’ll be first to test drive new products and solutions
You’ll learn how to accelerate your career
You’ll experience the power of community
|
This posting is provided "AS IS" with no warranties.
Tuesday, January 17, 2012
[Powershell] Configure Failover Management Server on SCOM Agent with Powershell
- # First retrieve information on the management servers
- $managementservers = get-managementserver
- $GTWServer1 = $managementservers | where {$_.Name -eq "GTWServer1.domain"};
- $GTWServer2 = $managementservers | where {$_.Name -eq "GTWServer2.domain"};
- # Settting up the failover between agents and Gateways
- Get-Agent -ManagementServer $GTWServer1 | foreach {set-managementserver -agentmanagedcomputer $_ -primarymanagementserver $GTWServer1 -failoverserver $GTWServer2 }
- Get-Agent -ManagementServer $GTWServer2 | foreach {set-managementserver -agentmanagedcomputer $_ -primarymanagementserver $GTWServer2 -failoverserver $GTWServer1 }
This posting is provided "AS IS" with no warranties.
Monday, January 16, 2012
SCOM 2012 Servers sizing for a small SCOM 2007 new deployment
I've also define 2 screnarios according to the Microsoft recommendations.
- scenario given by Microsoft – small deployment
HW Mini required
Role: Root Management Server• 2 disk RAID 1
• 4 GB RAM
• Dual Proc
Role: Operations Database Server, & Operations Data Warehouse Server (w/ SRS & Web Console Server)• 6 disk RAID 10 (147GB)
• 4 GB RAM
• Dual Proc
- More secure scenario
So here is the minimal requisite for a small SCOM 2012 infrastructure (Minimal Hardware is given since we don't have a the moment any Microsoft recommandations):
and here is a more secure Topology Diagram :
SQL DB/DW on a cluster
SQL reporting server on the passive node since cluster is not supported
Servers outside the domain 1 will be linked to MS + RMS (failover) by using certificate
Servers in Domain 1 will be attached to 2 gateways (one for failover)
Console will be installed on a management server
This posting is provided "AS IS" with no warranties.
Friday, January 13, 2012
TechNet Virtual Lab: System Center Operations Manager 2012: Infrastructure and Application Performance Monitoring
https://cmg.vlabcenter.com/default.aspx?moduleid=7a804b17-0025-4309-957d-a21c2e121e2b
Deploying the infrastructure for a private cloud is just the first step. Once it’s in place, IT administrators have to monitor those resources to ensure that the infrastructure SLAs are met, quickly find the causes for any problems, and plan for future growth.
This posting is provided "AS IS" with no warranties.
[OpsMgr 2007 R2][Powershell] Get Alerts for all specified SCOM MP using powershell in Operation Manager 2007 R2
- $mp = Get-ManagementPack -name 'MPName'
- # Criteria : All alerts, raw and processed descriptions.
- # Output to : File (c:\temp\output\Alerts-all.csv)
- # Fields Selected: Lots.
- # Output Format : CSV
- # Notes : Need more work on this.
- $alerts_csv = "C:\MPName.csv";
- write-host "Exporting all alerts to csv: ",$alerts_csv;
- Get-Alert | select-object @{Name = '%'; expression ={$_.MonitoringObjectDisplayName}},Severity, Name, ResolutionState, RepeatCount,@{Name = 'Instances'; expression ={$_.RepeatCount+1}},@{Name = 'Created'; expression =
- {$_.TimeRaised.ToLocalTime()}},@{Name = 'Description (Processed)';Expression = {$_.Description -replace "`n"," " -replace " "," "}},MonitoringObjectFullName, IsMonitorAlert,Id,MonitoringRuleId,MonitoringClassId,Description | sort Name | export-csv $alerts_csv -noTypeInformation;
An updated version for Operations Manager 2012 has been published >>>>>>>>>> here <<<<<<<<<<
This posting is provided "AS IS" with no warranties.
Thursday, December 1, 2011
[OpsMgr 2007] Timeout running Remove-DisabledMonitoringObject cmdlet in System Center Operations Manager
The resolution has been found too late !
First, here is our configuration - approximatly 3000 agents in CU3. We don't have upgraded to CU4 and we soon upgrade to CU5. SQL 2008 for the DBs.
The first thinking of why the cmdlet is timing out was the number of overrides was too much for the SDK to process before the thirty minute WCF(Windows Connection Framework) timeout occurs.
Within our production environment there are approximately 140000 DiscoverySources which need analyse be the cmdlet to know if the associated discovered types need to be removed or not. We have a pre-production environnemnt with less number of agents and only 40000 DiscoverySources on wich the cmdlet is well working.
To reduce the number of Discovery sources we have analysed all the MP we have and it appeared that OCS MP was responsible for almost 40% of the hugh number of DiscoverySources. The OCS MP has nineteen discoveries targeted at Windows Server Computer class enabled by default. On each discoveries we have an override on a group to disable disovery for the group members. A discoverysource entry is created for each discovery-to-target-entity mapping.
We have also : 19 * ~3000 agents = 57000 discoverysources just for OCS MP.
When overrides are done one theses discoveries, the enabled states must calculated for all discoverysources !
I've worked to remove some overrides and also to reduce the enabled state calculation for the DiscoverySources but the cmdlet was always timed out.
The next way to fix the issue was to let Microsoft have an other review of the code and SQL involved to see if they can make some efficiencies in the way they do this. I've also been asked to run 2 queries on the SCOM Database :
I’ve also run the following queries :
- SELECT COUNT (Distinct [DiscoverySource].[DiscoverySourceId])
- FROM dbo.DiscoverySource
- INNER JOIN dbo.ModuleOverride ON ModuleOverride.ParentId = DiscoverySource.DiscoveryRuleId
- AND ModuleOverride.OverrideableParameterId = dbo.fn_MPObjectId(NULL, NULL, N'Enabled')
- AND (ParentType = 'Discovery' OR ParentType = 'Rule')
- join DiscoverySourceToTypedManagedEntity dstme
- on discoverysource.DiscoverySourceId = dstme.DiscoverySourceId
- WHERE DiscoverySource.IsDeleted = 0
- AND ModuleOverride.Value = 'false'
- SELECT COUNT (Distinct [DiscoverySource].[DiscoverySourceId])
- FROM dbo.DiscoverySource
- INNER JOIN dbo.ModuleOverride ON ModuleOverride.ParentId = DiscoverySource.DiscoveryRuleId
- AND ModuleOverride.OverrideableParameterId = dbo.fn_MPObjectId(NULL, NULL, N'Enabled')
- AND (ParentType = 'Discovery' OR ParentType = 'Rule')
- join DiscoverySourceToTypedManagedEntity dstme
- on discoverysource.DiscoverySourceId = dstme.DiscoverySourceId
- WHERE DiscoverySource.IsDeleted = 0
- Run the SQL against the OperationsManager DB.
- DECLARE @querydef XML
- SET @querydef =
- N'<QueryDefinitions xmlns="urn:DataAccess" xmlns:dal="urn:DataAccess" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:DataAccess QueryDefinition.xsd">
- <QueryDefinition>
- <Name>DiscoverySourcesEligibleForDeletionDueToOverrides</Name>
- <ObjectName>DiscoverySourcesEligibleForDeletionDueToOverrides</ObjectName>
- <UsedBy Component="Sdk" />
- <Description>Selects discovery sources that *may* be invalid due to applied overrides.</Description>
- <DataObject xsi:type="SelectType">
- <Column>
- <Name>DiscoverySourceId</Name>
- <Source>DiscoverySource</Source>
- <Type>uniqueidentifier</Type>
- </Column>
- <Column>
- <Name>DiscoverySourceType</Name>
- <Source>DiscoverySource</Source>
- <Type>tinyint</Type>
- <EnumType>Microsoft.EnterpriseManagement.Mom.Modules.DataItems.Discovery.DiscoverySourceType</EnumType>
- <EnumLeastValue>Rule</EnumLeastValue>
- <EnumGreatestValue>ConfigService</EnumGreatestValue>
- </Column>
- <Column>
- <Name>DiscoveryRuleId</Name>
- <Source>DiscoverySource</Source>
- <Type>uniqueidentifier</Type>
- </Column>
- <Column>
- <Name>BoundManagedEntityId</Name>
- <Source>DiscoverySource</Source>
- <Type>uniqueidentifier</Type>
- </Column>
- <Argument>Distinct</Argument>
- <Source>
- <Table>
- <Name>DiscoverySource</Name>
- <Owner>dbo</Owner>
- <Type>Table</Type>
- </Table>
- <Join>
- <Type>Inner</Type>
- <Table>
- <Name>ModuleOverride</Name>
- <Owner>dbo</Owner>
- <Type>Table</Type>
- </Table>
- <JoinCondition>ModuleOverride.ParentId = DiscoverySource.DiscoveryRuleId AND ModuleOverride.OverrideableParameterId = dbo.fn_MPObjectId(NULL, NULL, N''Enabled'') AND (ParentType = ''Discovery'' OR ParentType = ''Rule'')</JoinCondition>
- </Join>
- <Join>
- <Type>Inner</Type>
- <Table>
- <Name>DiscoverySourceToTypedManagedEntity</Name>
- <Owner>dbo</Owner>
- <Type>Table</Type>
- </Table>
- <JoinCondition> discoverysource.DiscoverySourceId = DiscoverySourceToTypedManagedEntity.DiscoverySourceId</JoinCondition>
- </Join>
- </Source>
- <Conditional>
- <Condition>
- <Expression>DiscoverySource.IsDeleted = 0 AND ModuleOverride.Value = ''false''</Expression>
- </Condition>
- </Conditional>
- </DataObject>
- </QueryDefinition>
- </QueryDefinitions>'
- INSERT INTO dbo.[DataAccessLayerSetting]([SettingType], [SettingData]) VALUES (0, @querydef)
- Restart the OpsMgr SDK service.
- Run the remove-disabledmonitoringobject cmdlet and report back on the success or failure of it.
- get-managementserver | select ManagementGroup -unique
- get-date
- remove-disabledmonitoringobject
- get-date
Unfortunatly the 2 first time I've launched the remove-disabledmonitoringobject cmdlet, it went to a new error :
- >get-date
- Monday, November 28, 2011 8:27:16 AM
- PS Monitoring:\
- >remove-disabledmonitoringobject
- Remove-DisabledMonitoringObject : Microsoft.EnterpriseManagement.Common.DiscoveryDataFromRuleTargetedToDeletedMonitoringObjectException: Discovery data has been received from a rule targeted at a non-existent monitoring object id.
- MonitoringObjectId: c1537246-ec53-cc7c-b45f-aed87f06bc7f
- RuleId: 66b6d462-535f-cab6-eb14-b24fc79dfb75
- at Microsoft.EnterpriseManagement.DataAbstractionLayer.InstanceSpaceOperations.DeleteDisabledDiscoverySources()
- at Microsoft.EnterpriseManagement.ManagementGroup.DeleteDisabledMonitoringObjects()
- at Microsoft.EnterpriseManagement.OperationsManager.ClientShell.RemoveDisabledMonitoringObjectCmdlet.ProcessRecord()
- At line:1 char:32
- + remove-disabledmonitoringobject <<<<
- + CategoryInfo : InvalidOperation: (Microsoft.Enter...ingObjectCmdlet :RemoveDisabledMonitoringObjectCmdlet) [Remove-DisabledMonitoringObject], Disc
- overyDataFr...ObjectException + FullyQualifiedErrorId : ExecutionError,Microsoft.EnterpriseManagement.Operat
- ionsManager.ClientShell.RemoveDisabledMonitoringObjectCmdlet
- PS Monitoring:\
- >get-date
- Monday, November 28, 2011 8:48:55 AM
This posting is provided "AS IS" with no warranties.
[SCOM 2007] Authoring Management Pack - Create a VBS discovery with a debugging functionnality - PART II
- First part of the discovery script is to declare and set the variable
- Option Explicit
- SetLocale("en-us")
- '-----------------------------------------------------------------------------------------------------
- ' DEFAULT VARIABLES AND CONST - Used by the debuging functions and sub
- '-----------------------------------------------------------------------------------------------------
- Const REGKEYPATH = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft Operations Manager\Debugging"
- Const REGISTRYDEFVALUE = "FALSE"
- Const MOMEVENTLOGERROR = "1"
- Const MOMEVENTLOGWARNING = "2"
- Const MOMEVENTLOGINFORMATION = "4"
- Dim intIndex
- Dim strRegValue
- Dim strRegKeyName
- Dim strMPScriptName
- Dim strCurrentDebugModeValue
- Dim oAPI
- Dim oInst
- Dim oArgs
- Dim oDiscoveryData
- '-----------------------------------------------------------------------------------------------------
- ' SET THE FOLLOWING VALUES ACCORDING TO YOUR MANAGEMENT PACK
- '----------------------------------------------------------------------------------------------------
- strMPScriptName = "MyNewMP.DSC1.vbs"
- strRegKeyName = "Verbose.MyNewMP"
- '-----------------------------------------------------------------------------------------------------
- ' Create the object that connect to MOM API
- Set oAPI = CreateObject("MOM.ScriptAPI")
- '-----------------------------------------------------------------------------------------------------
- ' DEFAULT FUNCTIONS - Used for Management Pack debugging
- '-----------------------------------------------------------------------------------------------------
- Private Function fct_ReadRegistryKey(ByVal strKeyPath, ByVal strKeyName)
- 'Read Registry key located on KeyPath\KeyName
- 'Returns the value of a registry key and eventually a no-value to identify that the key does not exists.
- Dim oWshShell
- Dim strRegReadValue 'Contains the value of the Registry Key
- 'Try to read the registry key located to strKeyPath\strKeyName
- On Error Resume Next
- Set oWshShell = CreateObject("Wscript.Shell")
- strRegReadValue = oWshShell.RegRead(strKeyPath &"\" & strKeyName)
- 'If an error is raised Then we a no-value to identify that the Registry Key does not exist.
- If err.number <> 0 Then
- strRegReadValue = ""
- End if
- On error goto 0
- fct_ReadRegistryKey = UCase(strRegReadValue)
- End Function
- '-----------------------------------------------------------------------------------------------------
- Private Function fct_WriteRegistryKey(ByVal strKeyPath, ByVal strKeyName, ByVal strKeyValue)
- ' Write a Registry value to strKeyPath\strKeyName with value strKeyValue
- ' blnKeyEdit is set to True or false in case of error.
- Dim blnKeyEdit
- Dim oWshShell
- blnKeyEdit = false
- 'Try to set strKeyValue to the registry key strKeyPath\strKeyName
- On Error Resume Next
- Set oWshShell = WScript.CreateObject("WScript.Shell")
- oWshShell.RegWrite strKeyPath & "\" & strKeyName , UCase(strKeyValue)
- 'If setting the registry key strKeyValue is OK Then the function will return a string TRUE.
- If err.number = 0 Then
- blnKeyEdit = true
- End if
- On error goto 0
- fct_WriteRegistryKey = blnKeyEdit
- End Function
- '-----------------------------------------------------------------------------------------------------
- Private Sub sub_LogMPScriptEvent(ByVal intErrNumber, ByVal strEventLogMessage, ByRef objError, ByVal strDebugMod, ByVal strScriptName, ByVal strMomEventLevel)
- ' Log an event in the OperationManager eventLog of the server if it is in debug mode
- ' It will allow to trace the debugging process of the script of the Management Pack by logging errors and parameters values
- Dim strMessage
- strMessage=""
- 'If the debug mode is ON, an event is logged in the Operation Manager eventLog.
- If ucase(strDebugMod) = "TRUE" Then
- strMessage = strEventLogMessage & vbCrLf & " " & vbCrLf & _
- "Error number:" & vbTab & CStr(objError.Number) & vbCrLf & _
- "Error description:" & vbTab & objError.Description
- Call oAPI.LogScriptEvent(strScriptName, intErrNumber, strMomEventLevel, strMessage)
- End if
- End Sub
- '-----------------------------------------------------------------------------------------------------
- Private function fct_LogRunningAccount(ByVal strDebugMode)
- ' Log an event in the OperationManager eventLog of the server if it is in debug mode
- ' It allows to know under which credentials the script is executed
- Dim owshNetwork
- Dim strRunningUserID
- On Error Resume Next
- Set owshNetwork = WScript.CreateObject("WScript.Network")
- 'Assign user name returned to a variable
- strRunningUserID = owshNetwork.UserName
- call sub_LogMPScriptEvent (4005, "sub_LogMPScriptEvent. Script running as user: " & strRunningUserID , Err, strDebugMode,strMPScriptName,MOMEVENTLOGINFORMATION)
- On error goto 0
- fct_LogRunningAccount = strRunningUserID
- End Function
- '-----------------------------------------------------------------------------------------------------
- private sub sub_LogScriptStartInfo(byRef oArgs, byVal strDebugModeValue, byval strMomLevelEvent, byVal strScriptName)
- ' Log an event with the default informations. The event contains :
- ' - The account used to run the script
- ' - The number of script parameters
- ' - The values of the parameters
- ' - The value of the debug mode
- Dim owshNetwork
- Dim strLogMessage
- Dim strRunAsAccount
- On Error Resume Next
- Set owshNetwork = WScript.CreateObject("WScript.Network")
- 'Assign user name returned to a variable
- strRunAsAccount = owshNetwork.UserName
- strLogMessage=""
- ' Create the start log Script with launch information data RunAs account, debugmode, arguments)
- strLogMessage = vbcrlf & "The script has been launched under following credentials : " & strRunAsAccount & "." & vbcrlf & vbcrlf & oArgs.count & " arguments have been passed in parameter : "
- For intIndex = 0 To oArgs.Count-1
- strLogMessage = strLogMessage & vbcrlf & " - " & oArgs(intIndex)
- Next
- strLogMessage = strLogMessage & vbcrlf & vbcrlf & "The debug mode value for the Management Pack is set to : " & strDebugModeValue
- Call oAPI.LogScriptEvent(strScriptName, 10212, strMomLevelEvent, strLogMessage)
- End sub
- '-----------------------------------------------------------------------------------------------------
- '-----------------------------------------------------------------------------------------------------
- ' MAIN CODE START HERE
- '-----------------------------------------------------------------------------------------------------
- ' Gets the arguments passed in parameters of the script
- Set oArgs = Wscript.Arguments
- ' If the minimals arguments are not set then we exit the script
- if oArgs.Count < 3 Then
- Wscript.Quit -1
- End If
- ' Check the value of the registry key on the server to know if the debug mode is ON or not
- 'By default the registry key is set to : DOES NOT EXIST. See fct_ReadRegistryKey for more information
- strRegValue = fct_ReadRegistryKey(REGKEYPATH, strRegKeyName)
- 'If the registry key is TRUE XOR FALSE then the debugmodevalue has a good value
- If ((strRegValue = "TRUE") Xor (strRegValue = "FALSE")) Then
- strCurrentDebugModeValue = strRegValue
- Else
- 'If the registry key is empty or not correctly set then a attempt to set to default value is made.
- If fct_WriteRegistryKey(REGKEYPATH, strRegKeyName, REGISTRYDEFVALUE) Then
- ' write event 10211 that says the registry key has been created
- call sub_LogMPScriptEvent (10211, "Registry Key " & REGKEYPATH & "\" & strRegKeyName & " With Value = " & REGISTRYDEFVALUE & " has been created", Err, True,strMPScriptName,MOMEVENTLOGINFORMATION)
- Else
- ' write event 10210 that says the registry key has not been created
- call sub_LogMPScriptEvent (10210, "Error in creation of the Registry Key " & REGKEYPATH & "\" & strRegKeyName & " With Value = " & REGISTRYDEFVALUE , Err, True,strMPScriptName,MOMEVENTLOGERROR)
- End if
- strCurrentDebugModeValue = REGISTRYDEFVALUE
- End if The discovery itself : 'Return Data to the Management PackCall oDiscoveryData.AddInstance(oInst)
- Dim intSourceType
- Dim strSourceId0
- Dim strTargetComputer
- Dim strManagedEntityId
- intSourceType =
- 'Set the arguments for creating the default Management Pack modules.strSourceId = oArgs(0)
- strManagedEntityId = oArgs(1)
- strTargetComputer = oArgs(2)
- 'Create the default management pack classSet oDiscoveryData = oAPI.CreateDiscoveryData(intSourceType, strSourceId, strManagedEntityId)
- Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='MyNewMP.CLS1']$")
- call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", strTargetComputer)
- call oInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "MyNewMP")
- call oInst.AddProperty("$MPElement[Name='MyNewMP.CLS1']/DebugMod$", strCurrentDebugModeValue)
- call sub_LogMPScriptEvent (10213, "Server "& strTargetComputer & " has been discovered. The debug mode value on this server is set to " & strCurrentDebugModeValue, Err, strCurrentDebugModeValue,strMPScriptName,MOMEVENTLOGINFORMATION)
- '-----------------------------------------------------------------------------------------------------
- ' PUT YOUR DISCOVERY CODE AFTER
- '-----------------------------------------------------------------------------------------------------
- 'Return Data to the Management PackCall oDiscoveryData.AddInstance(oInst)
- Call oAPI.Return(oDiscoveryData)
This posting is provided "AS IS" with no warranties.












