Dell Run As Account Associator Probe

Dell.PowerShellAPITaskProbe.OverrideCreator (ProbeActionModuleType)

Element properties:

TypeProbeActionModuleType
IsolationAny
AccessibilityPublic
RunAsDefault
InputTypeSystem.TriggerData
OutputTypeSystem.PropertyBagData

Member Modules:

ID Module Type TypeId RunAs 
PSP ProbeAction Microsoft.Windows.PowerShellPropertyBagProbe Default

Overrideable Parameters:

IDParameterTypeSelectorDisplay NameDescription
IntervalSecondsint$Config/IntervalSeconds$Interval Seconds for Run As Account Associator ProbeInterval Seconds for Run As Account Associator Probe

Source Code:

<ProbeActionModuleType ID="Dell.PowerShellAPITaskProbe.OverrideCreator" Accessibility="Public" Batching="false" PassThrough="false">
<Configuration>
<IncludeSchemaTypes>
<SchemaType>Dell.OperationsLibrary.Common.ImportMethod</SchemaType>
<SchemaType>Dell.OperationsLibrary.Common.MonitoringLevel</SchemaType>
</IncludeSchemaTypes>
<xsd:element minOccurs="1" name="IntervalSeconds" type="xsd:integer"/>
<xsd:element minOccurs="1" name="LogLevel" type="xsd:integer"/>
<xsd:element minOccurs="1" name="LogDirectory" type="xsd:string"/>
<xsd:element minOccurs="1" name="TimeoutSeconds" type="xsd:integer"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="IntervalSeconds" Selector="$Config/IntervalSeconds$" ParameterType="int"/>
</OverrideableParameters>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<ProbeAction ID="PSP" TypeID="Windows!Microsoft.Windows.PowerShellPropertyBagProbe">
<ScriptName>RunAsAccountAssociator.ps1</ScriptName>
<ScriptBody><Script>
# ------------------------------------------------- #
# Script : Management Server Connection Script #
# Author: Vaideeswaran Ganesan #
# (c) Copyright Dell Inc. 2011- All rights reserved #
# ------------------------------------------------- #

param($intervalSeconds, $logLevel, $logDirectory)
$scriptname = 'DellRunAsAccountAssociator'

$MSComputerName = (hostname)

$DebugScript = $false

function Write-Info
{
param ([string] $msg)
Write-Host $msg
}
function Write-WarningInfo
{
param ([string] $msg)
Write-Host $msg
}
function Write-ErrorInfo
{
param ([string] $msg)
Write-Host $msg
}

# Logging Header
If ($logLevel -ne 0)
{
$TempFolder = [environment]::GetEnvironMentVariable("temp","machine")
$LogLocation = $TempFolder + "\" + $logDirectory + "\"
If(!(Test-Path -path($TempFolder)))
{
# create the directory if not present
New-Item $TempFolder -type directory
}

If(!(Test-Path -path($LogLocation)))
{
# create the directory if not present
New-Item $LogLocation -type directory
}
$Global:LogFileLocation = $LogLocation + $scriptname + ".log"
If(!(Test-Path -path($LogFileLocation)))
{
# create the file if it does not exist
New-Item $LogFileLocation -type file
}
Else
{
$logFileSize = Get-ChildItem $LogFileLocation | ForEach-Object {($_.Length/1KB)}
If ($logFileSize -gt 512)
{
# existingLogFile is greater than 512 KB
$archiveTime = Get-Date -f "yyyy-MM-dd_HH.mm"
Rename-Item $LogFileLocation ("ArchivedLog_" + $scriptname + "_" + $archiveTime + ".log")
New-Item $LogFileLocation -type file
}
}
}


# -----------------------------------------------------------------------------------
# Creating new SCE2010 Module - for connection to SCE and SCE task functionality
# -----------------------------------------------------------------------------------
$sce2010Interface = new-module {
[object]$connection = $null
[string] $state = ''
[string] $loglocation = '.\test.log'
[int] $loglevel = 1
[string] $product = "SCE 2010"

function Write-Info
{
param ([string] $msg)
#Write-Host $msg
}

Function psDebugLog
{
param($level, $message)
if (($level -gt 0) -and ($level -le $logLevel))
{
$currentTime = Get-Date -f "yyyy-MM-dd_HH.mm.ss"
Out-File -FilePath $this.loglocation -InputObject ($currentTime + " :: " + $message) -Append
}
}

function GetConnection()
{
psDebugLog -level 1 -message $this.state
$this.connection = [Microsoft.EnterpriseManagement.ManagementGroup]::connect("localhost")
$this.state = 'connected'
}

function LoadSnapins()
{
[System.Reflection.Assembly]::LoadFile("C:\Program Files\System Center Essentials\SDK Binaries\Microsoft.EnterpriseManagement.OperationsManager.Common.dll") &gt; $null
[System.Reflection.Assembly]::LoadFile("C:\Program Files\System Center Essentials\SDK Binaries\Microsoft.EnterpriseManagement.OperationsManager.dll") &gt; $null
$this.state = 'snapins loaded'
}

Function GetManagementPacks()
{
psDebugLog -level 1 -message $this.state
return $this.connection.GetManagementPacks()
}

function InstallManagementPack($ImportPath)
{
$v = $null
try {
$this.connection.ImportManagementPack($ImportPath)
} catch {
$v = $_
}
return $v
}

function UninstallManagementPack($ManagementPack)
{
$this.connection.UninstallManagementPack($ManagementPack)
$v = $null
return $v
}

function PrintDebug()
{
Write-Info -msg ("Product: " + $this.Product)
Write-Info -msg ("State: " + $this.State)
}

function GetSCOMInstallDir()
{
return $(Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Microsoft Operations Manager\3.0\Setup").InstallDirectory;
}

function GetManagementGroup()
{
return $this.connection
}

Export-ModuleMember -function * -variable *
} -asCustomObject

# -----------------------------------------------------------------------------------
# Creating new SCOM2007 R2 Module - for connection to 2007R2 and 2007R2 task functionality
# -----------------------------------------------------------------------------------
$scom2007r2Interface = new-module {
[object]$connection = $null
[string] $state = ''
[string] $loglocation = '.\test.log'
[int] $loglevel = 1
[string] $product = "SCOM 2007 R2"

function Write-Info
{
param ([string] $msg)
#Write-Host $msg
}

Function psDebugLog
{
param($level, $message)
if (($level -gt 0) -and ($level -le $logLevel))
{
$currentTime = Get-Date -f "yyyy-MM-dd_HH.mm.ss"
Out-File -FilePath $this.loglocation -InputObject ($currentTime + " :: " + $message) -Append
}
}

function GetConnection()
{
psDebugLog -level 1 -message $this.state
$MachineRegErrorMsg = "Can not find Operations Manager Management Server name for the local machine.";
$UserRegKeyPath = "HKCU:\software\Microsoft\Microsoft Operations Manager\3.0\User Settings";
$MachineRegKeyPath = "HKLM:\software\Microsoft\Microsoft Operations Manager\3.0\Machine Settings";
$UserRegValueName = "SDKServiceMachine";
$MachineRegValueName = "DefaultSDKServiceMachine";
$ConnectingMsg = "Connecting to Operations Manager Management Server '{0}'.";
$ConnectErrorMsg = "Can not connect to Operations Manager Management Server '{0}'.";
$AccessDeniedErrorMsg = "Access is denied to Operations Manager Management Server '{0}'.";

$regKey = $null;
$regValue = $null;

# Set the initial server value to the MS argument.
# If the argument is empty the normal registry lookup sequence will kickin.
# If the argument is not empty the user will be connected to the specified connection.
$server = $null;

# Get the User Operations Manager Product Registry Key
if ($server -eq $null -or $server.Length -eq 0)
{
$regValue = Get-ItemProperty -path:$UserRegKeyPath -name:$UserRegValueName -ErrorAction:SilentlyContinue;

if ($regValue -ne $null)
{
$server = $regValue.SDKServiceMachine;
}
}

if ($server -eq $null -or $server.Length -eq 0)
{
# Get the Machine Operations Manager Product Registry Key if the user setting could not be found.
$regValue = Get-ItemProperty -path:$MachineRegKeyPath -name:$MachineRegValueName -ErrorAction:SilentlyContinue;

if ($regValue -ne $null)
{
$server = $regValue.DefaultSDKServiceMachine;
}
}

# If the default Operations Manager Management Server name can not be found in the registry then default to 'localhost'.
if ($server -eq $null -or $server.Length -eq 0)
{
psDebugLog -level 1 -message ($MachineRegErrorMsg)
$server = "localhost";
}

# Create a connection and make it the current location.
if ($server -ne $null -and $server.Length -gt 0)
{
# Format the connecting message.
$msg = $ConnectingMsg -f $server;
psDebugLog -level 1 -message ($msg)

# Create the new connection.
$error.Clear();
$this.connection = New-ManagementGroupConnection -ConnectionString:$server -ErrorAction:SilentlyContinue
psDebugLog -level 1 -message ("After : " + $msg)
if ($this.connection -ne $null)
{
psDebugLog -level 1 -message ("Connection Success! " + $this.connection)
}

# If the connection failed due to insufficient access then prompt for credentials.
if ($error.Count -gt 0 -and $error[0].Exception -is [Microsoft.EnterpriseManagement.Common.UnauthorizedAccessMonitoringException])
{
psDebugLog -level 1 -message ("Failed to connect")
$error.Clear();
}

if ($error.Count -gt 0 -and $error[0].Exception -is [Microsoft.EnterpriseManagement.Common.UnauthorizedAccessMonitoringException])
{
$errMsg = $AccessDeniedErrorMsg -f $server;
psDebugLog -level 1 -message $errMsg
}

if ($this.connection -eq $null)
{
$errMsg = $ConnectErrorMsg -f $server;
psDebugLog -level 1 -message $errMsg
}
}

if ($this.connection -ne $null)
{
psDebugLog -level 1 -message ("Setting to path: " + "OperationsManagerMonitoring::")
Set-Location "OperationsManagerMonitoring::"
psDebugLog -level 1 -message ("Current Directory: " + (pwd).Path)
psDebugLog -level 1 -message ("Setting to path: " + $server)
Set-Location $server;
psDebugLog -level 1 -message ("Current Directory: " + (pwd).Path)
}
$this.state = 'connected'
return $this.connection

}

function LoadSnapins()
{
$snapin = (Get-PsSnapin Microsoft.EnterpriseManagement.OperationsManager.Client -ErrorVariable $snapinerr -ErrorAction:SilentlyContinue)
if ($snapin -eq $null)
{
Add-PsSnapin Microsoft.EnterpriseManagement.OperationsManager.Client -ErrorVariable $snapinerr -ErrorAction:SilentlyContinue
if ($snapinerr -eq $null -or $snapinerr.Count -eq 0) {
# successful!
psDebugLog -level 1 -message "Snapin succeeded"
}
else
{
psDebugLog -level 1 -message "Snapin Failed"
psDebugLog -level 1 -message $snapinerr
}
}
$this.state = 'snapins loaded'
}

Function GetManagementPacks()
{
psDebugLog -level 1 -message $this.state
return (Get-ManagementPack)
}

function InstallManagementPack($ImportPath)
{
Install-ManagementPack -filepath $ImportPath -ErrorAction:SilentlyContinue -ErrorVariable v
return $v
}

function UninstallManagementPack($ManagementPack)
{
Uninstall-ManagementPack -ManagementPack $ManagementPack -ErrorAction:SilentlyContinue -ErrorVariable v
return $v
}

function PrintDebug()
{
Write-Info -msg ("Product: " + $this.Product)
Write-Info -msg ("State: " + $this.State)
}

function GetSCOMInstallDir()
{
return $(Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Microsoft Operations Manager\3.0\Setup").InstallDirectory;
}

function GetManagementGroup()
{
return $this.connection.ManagementGroup
}

Export-ModuleMember -function * -variable *
} -asCustomObject

# -----------------------------------------------------------------------------------
# Creating new SCOM2012 Module - for connection to 2012 and 2012 task functionality
# -----------------------------------------------------------------------------------
$scom2012Interface = new-module {
[object]$connection = $null
[string] $state = ''
[string] $loglocation = '.\test.log'
[int] $loglevel = 1
[string] $product = "SCOM 2012"
[object]$mgmtGroup = $null

function Write-Info
{
param ([string] $msg)
#Write-Host $msg
}

Function psDebugLog
{
param($level, $message)
if (($level -gt 0) -and ($level -le $logLevel))
{
$currentTime = Get-Date -f "yyyy-MM-dd_HH.mm.ss"
Out-File -FilePath $this.loglocation -InputObject ($currentTime + " :: " + $message) -Append
}
}

function GetConnection()
{
psDebugLog -level 1 -message $this.state

$managementServerName = ""
$persistConnection = $false
$interactive = $false
$MachineRegErrorMsg = "Can not find Operations Manager Management Server name for the local machine.";
$UserRegKeyPath = "HKCU:\software\Microsoft\Microsoft Operations Manager\3.0\User Settings";
$MachineRegKeyPath = "HKLM:\software\Microsoft\Microsoft Operations Manager\3.0\Machine Settings";
$UserRegValueName = "SDKServiceMachine";
$MachineRegValueName = "DefaultSDKServiceMachine";
$ConnectingMsg = "Connecting to Operations Manager Management Server '{0}'.";
$ConnectErrorMsg = "Can not connect to Operations Manager Management Server '{0}'.";
$AccessDeniedErrorMsg = "Access is denied to Operations Manager Management Server '{0}'.";
$ConnectPromptMsg = "Enter the name of the Operations Manager Management Server to connect to.";
$ConnectPrompt = "Management Server";
$serviceNotRunningErrorMsg = "The Data Access service is either not running or not yet initialized. Check the event log for more information.";
$HostNotFoundErrorMsg = "No such host is known";

$regKey = $null;
$regValue = $null;

# Set the initial server value to the MS argument.
# If the argument is empty the normal registry lookup sequence will kickin.
# If the argument is not empty the user will be connected to the specified connection.
$server = $managementServerName;
$drive = $null;

# Get the User Operations Manager Product Registry Key
if ($server -eq $null -or $server.Length -eq 0)
{
$regValue = Get-ItemProperty -path:$UserRegKeyPath -name:$UserRegValueName -ErrorAction:SilentlyContinue;

if ($regValue -ne $null)
{
$server = $regValue.SDKServiceMachine;
}
}

if ($server -eq $null -or $server.Length -eq 0)
{
# Get the Machine Operations Manager Product Registry Key if the user setting could not be found.
$regValue = Get-ItemProperty -path:$MachineRegKeyPath -name:$MachineRegValueName -ErrorAction:SilentlyContinue;

if ($regValue -ne $null)
{
$server = $regValue.DefaultSDKServiceMachine;
}
}

# If the default Operations Manager Management Server name can not be found in the registry then default to 'localhost'.
if ($server -eq $null -or $server.Length -eq 0)
{
psDebugLog -level 1 -message $MachineRegErrorMsg
$server = "localhost";
}

# Create a connection and make it the current location.
$this.connection = $null;

if ($server -ne $null -and $server.Length -gt 0)
{
# Format the connecting message.
$msg = $ConnectingMsg -f $server;
psDebugLog -level 1 -message $msg

# Create the new connection.
$this.connection = New-SCOMManagementGroupConnection -ComputerName: $server -PassThru -ErrorAction:Stop
}
$this.state = 'connected'
$this.mgmtGroup = Get-SCOMManagementGroup
return $this.connection
}

function PrintDebug()
{
Write-Info -msg ("Product: " + $this.Product)
Write-Info -msg ("State: " + $this.State)
}

function LoadSnapins()
{
Import-Module OperationsManager
$this.state = 'snapins loaded'
}

Function GetManagementPacks()
{
psDebugLog -level 1 -message $this.state
return (Get-SCManagementPack)
}

function InstallManagementPack($ImportPath)
{
Import-SCManagementPack $ImportPath -ErrorAction:SilentlyContinue -ErrorVariable v
return $v
}

function UninstallManagementPack($ManagementPack)
{
Remove-SCManagementPack -ManagementPack $ManagementPack -ErrorAction:SilentlyContinue -ErrorVariable v
return $v
}

function GetSCOMInstallDir()
{
return $(Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Microsoft Operations Manager\3.0\Setup").InstallDirectory;
}

function GetManagementGroup()
{
return $this.mgmtGroup
}

Export-ModuleMember -function * -variable *
} -asCustomObject


# Now, activate the appropriate customObjectmodule (SCOM2012, SCE2010 or SCOM2007R2)
# based on presence detected on mgmtServer

$MachineRegKeyPath = "HKLM:\software\Microsoft\Microsoft Operations Manager\3.0\Setup";
$MachineRegValueName = "SKU";
$skuName = $null; $skuVersion = $null
$skuName = Get-ItemProperty -path:$MachineRegKeyPath -name:$MachineRegValueName -ErrorAction:SilentlyContinue;
$skuVersion = Get-ItemProperty -path:$MachineRegKeyPath -name:"CurrentVersion" -ErrorAction:SilentlyContinue;
Write-Info -msg ("SKU: " + $skuName.SKU)
Write-Info -msg ("CurrentVersion: " + $skuVersion.CurrentVersion)
if ($skuName.InstallDirectory -match "Essentials")
{
$scomenv = $sce2010Interface
}
elseif ( $skuName.InstallDirectory -match "2007" )
{
$scomenv = $scom2007r2Interface
}
else
{
$scomenv = $scom2012Interface
}
$scomenv.loglocation = $LogFileLocation
$scomenv.LogLevel = $LogLevel
$scomenv.LoadSnapins()
$scomenv.PrintDebug()
$scomenv.GetConnection()


# -----------------------------------------------------------------------
# includes timestamp, msg and supports archiving over 512 KB
# ------------------------------------------------------------------------
Function psDebugLog
{
param($level, $message)
if (($level -gt 0) -and ($level -le $logLevel))
{
$currentTime = Get-Date -f "yyyy-MM-dd_HH.mm.ss"
Out-File -FilePath $LogFileLocation -InputObject ($currentTime + " :: " + $message) -Append
}
}

psDebugLog -level 1 -message ("----------------------------------------------")
psDebugLog -level 1 -message ("Begin of " + $scriptname + " Discovery script ")
psDebugLog -level 1 -message ("ComputerName : " + $MSComputerName)
psDebugLog -level 1 -message ("ManagedEntityId : " + $managedEntityID)
psDebugLog -level 1 -message ("sourceID : " + $sourceID)

$mpname = 'Dell.SecureReference.Override'
$mpdesc = 'Dell.SecureReference.Override file'
$oneDiscoveryTgtClassName = 'Microsoft.SystemCenter.OOB.WSManDevice'
$oneDiscoveryGenClassName = 'Dell.Server'
$oneDiscoveryTgtClassGroupName = 'Microsoft.SystemCenter.OOB.WSManDeviceGroup'
$oneOverrideName = 'SecureRef-{0}'

# License Configuration
$mpStore = New-Object Microsoft.EnterpriseManagement.Configuration.IO.ManagementPackFileStore;
$scomInstallDir = $scomenv.GetSCOMInstallDir()
$mpStore.AddDirectory($scomInstallDir);
$mpStore.AddDirectory($dellsuitedir);
$mpXmlWriter = New-Object Microsoft.EnterpriseManagement.Configuration.IO.ManagementPackXmlWriter($scomInstallDir);

$mgmtGroup = $scomenv.GetManagementGroup()

$oneDiscoveryTgtClassCriteria = New-Object Microsoft.EnterpriseManagement.Configuration.MonitoringClassCriteria($("Name='{0}'" -f $oneDiscoveryTgtClassName));
$retVal = $mgmtGroup.GetMonitoringClasses($oneDiscoveryTgtClassCriteria)
if ($retVal -eq $null -or $retVal.Count -le 0)
{
# Do Error Condition Return

}
$oobWsManDeviceClass = $retVal[0]

$oneDiscoveryTgtClassGroupCriteria = New-Object Microsoft.EnterpriseManagement.Configuration.MonitoringClassCriteria($("Name='{0}'" -f $oneDiscoveryTgtClassGroupName));
$retVal = $mgmtGroup.GetMonitoringClasses($oneDiscoveryTgtClassGroupCriteria)
if ($retVal -eq $null -or $retVal.Count -le 0)
{
# Do Error Condition Return

}
$oobWsManDeviceGroupClass = $retVal[0]

$oneDiscoveryGenClassCriteria = New-Object Microsoft.EnterpriseManagement.Configuration.MonitoringClassCriteria($("Name='{0}'" -f $oneDiscoveryGenClassName));
$retVal = $mgmtGroup.GetMonitoringClasses($oneDiscoveryGenClassCriteria)
if ($retVal -eq $null -or $retVal.Count -le 0)
{
# Do Error Condition Return

}
$dellServerClass = $retVal[0]

$dellServerInstCriteria = New-Object Microsoft.EnterpriseManagement.Monitoring.MonitoringObjectCriteria("", $dellServerClass)
$dellServerInstances = $mgmtGroup.GetMonitoringObjects($dellServerInstCriteria)

$secRefOverridesMPCriteria = New-Object Microsoft.EnterpriseManagement.Configuration.ManagementPackCriteria($("Name='{0}'" -f 'Microsoft.SystemCenter.SecureReferenceOverride'));
$retVal = $mgmtGroup.GetManagementPacks($secRefOverridesMPCriteria)
if ($retVal -eq $null -or $retVal.Count -le 0)
{
# Do Error Condition Return

}
$secRefOverridesMP = $retVal[0]

$mpSecRefArray = @{}
$mpsecRef = $secRefOverridesMP.GetOverrides() | where { $_.XmlTag -eq 'SecureReferenceOverride' }
if ($mpsecRef -ne $null)
{
foreach ($sec in $mpsecRef)
{
if ($sec.ContextInstance -ne $null) {
$mpSecRefArray += @{ $sec.ContextInstance = $sec.Value }
Write-Host ($sec.ContextInstance.ToString() + " = " + $sec.Value)
}
}
}

$mpReferences = @{
'OperationsLibrary' = 'Dell.OperationsLibrary.Common'
'SystemCenter' = 'Microsoft.SystemCenter.Library'
'NetworkDevice' = 'Microsoft.SystemCenter.NetworkDevice.Library'
}

# Get the Override Management Pack
$ovrdMP = $scomenv.GetManagementPacks() | where-object { $mpname -eq $_.Name }
if ($ovrdMP -eq $null)
{
# Create a new management pack, if not present
$ovrdMP = New-Object Microsoft.EnterpriseManagement.Configuration.ManagementPack($mpname, $mpdesc, (New-Object Version(1, 0, 0)), $mpStore);
$mgmtGroup.ImportManagementPack($ovrdMP);
}
else
{
$mpsecRef = $secRefOverridesMP.GetOverrides() | where { $_.XmlTag -eq 'SecureReferenceOverride' }
if ($mpsecRef -ne $null)
{
foreach ($sec in $mpsecRef)
{
if ($sec.ContextInstance -ne $null -and $mpSecRefArray.Contains($sec.ContextInstance) -ne $true) {
$mpSecRefArray += @{ $sec.ContextInstance = $sec.Value }
Write-Host ($sec.ContextInstance.ToString() + " = " + $sec.Value)
}
}
}
}

# Add the MP References. REVISIT: Update References
foreach ($mpRef in $mpReferences.Keys)
{
if ($ovrdMP.References.ContainsKey($mpref) -eq $false)
{
# if $ovrdMP.References[$mpref].Version -lt $refmp.Version, update
$refmp = $scomenv.GetManagementPacks() | where { $_.Name -eq $mpReferences[$mpRef] }
$mprefcons = New-Object Microsoft.EnterpriseManagement.Configuration.ManagementPackReference($refmp, $refmp.Name, $refmp.KeyToken, $refmp.Version);
$ovrdMP.References.Add($mpref, $mprefcons)
} elseif ($ovrdMP.References[$mpref].Version -lt $refmp.Version) {
$refmp = $scomenv.GetManagementPacks() | where { $_.Name -eq $mpReferences[$mpRef] }
$mprefcons = New-Object Microsoft.EnterpriseManagement.Configuration.ManagementPackReference($refmp, $refmp.Name, $refmp.KeyToken, $refmp.Version);
$ovrdMP.References.Remove($mpref)
$ovrdMP.References.Add($mpref, $mprefcons)
}
}

$smshCriteria = New-Object Microsoft.EnterpriseManagement.Configuration.MonitoringSecureReferenceCriteria("Name='{0}'" -f 'Microsoft.SystemCenter.OOB.SMASHMonitoringProfile')
$retVal = $mgmtGroup.GetMonitoringSecureReferences($smshCriteria)
if ($retVal -eq $null -or $retVal.Count -le 0)
{
# Do Error Condition Return

}
$smashprofile = $retVal[0]

$oneOverrideName = 'SecureRef-{0}-hola-{1}'
$dellServerHashMap = @{}
$dellServerSecRefHashMap = @{}
Foreach ($server in $dellServerInstances)
{
$property_RemoteAccessIP = $server.GetMonitoringProperties() | where { $_.Name -eq 'RemoteAccessIP' }
$serverIP = $server.GetMonitoringPropertyValue($property_RemoteAccessIP)
$dellServerHashMap += @{ $serverIP = $server }

$oobDeviceForServer = $null
$server.GetMonitoringRelationshipObjects() | foreach -process {
if ($_.TargetMonitoringObject.IsInstanceOf($oobWsManDeviceClass))
{
$oobDeviceForServer = $_.TargetMonitoringObject
}
}

$oobServerWsManGroup = $null
$oobDeviceForServer.GetMonitoringRelationshipObjects() | foreach -process {
if ($_.SourceMonitoringObject.IsInstanceOf($oobWsManDeviceGroupClass))
{
$oobServerWsManGroup = $_.SourceMonitoringObject
}
}
$secrefVal = $null
$secrefKey=$null
foreach ($cls in $oobServerWsManGroup.GetMonitoringClasses())
{
if ($cls.Name -match 'Microsoft.SystemCenter.OOB.*.DeviceGroup')
{
$secrefKey =$cls.Name -replace ".DeviceGroup",""
$secrefVal = $cls.GetManagementPack().GetOverrides() | where { $_.XmlTag -eq 'SecureReferenceOverride' -and $_.Name -match $secrefKey}
}
}

$dellServerSecRefHashMap += @{ $serverIP = $secrefVal.Value }

$overrideDisplayName = ($oneOverrideName -f $server.Id, $server.Name)
$override = (($overrideDisplayName.Replace(" ", [String]::Empty)) -replace '-', '_')

if ($mpSecRefArray.Contains($server.Id) -eq $false)
{
# REVISIT Update if override not found!
$secref = New-Object Microsoft.EnterpriseManagement.Configuration.ManagementPackSecureReferenceOverride($ovrdMP, $override)
$secref.Value = $secrefVal.Value
$secref.Context = $dellServerClass
$secref.ContextInstance = $server.Id
$secref.SecureReference = $smashprofile
}
else
{
write-host ("Not adding " + $server.Id + ". Already exists")

}
}

# verify the changes in the override management pack
$ovrdMP.Verify();

# save the changes into the override management pack
try { $ovrdMP.AcceptChanges() }
catch [Exception] { $_ | fl * -Force }

psDebugLog -level 1 -message ("End of " + $scriptname + " Discovery script ")
psDebugLog -level 1 -message "----------------------------------------------"
</Script></ScriptBody>
<Parameters>
<Parameter>
<Name>IntervalSeconds</Name>
<Value>$Config/IntervalSeconds$</Value>
</Parameter>
<Parameter>
<Name>logLevel</Name>
<Value>$Config/LogLevel$</Value>
</Parameter>
<Parameter>
<Name>logDirectory</Name>
<Value>$Config/LogDirectory$</Value>
</Parameter>
</Parameters>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
</ProbeAction>
</MemberModules>
<Composition>
<Node ID="PSP"/>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.PropertyBagData</OutputType>
<InputType>System!System.TriggerData</InputType>
</ProbeActionModuleType>