O365 SMP O365ConsumedUnitsCollection V1 Script Performance Rule ProbeActionModuleType

O365.SMP.O365ActiveUnitsCollection_V1.Script.Performance.Rule.ProbeActionModuleType (ProbeActionModuleType)

Probe Action Module Type for Performance Rule: O365.SMP.O365ActiveUnitsCollection_V1.Script.Performance.Rule

Element properties:

TypeProbeActionModuleType
IsolationAny
AccessibilityInternal
RunAsDefault
OutputTypeSystem.PropertyBagData

Member Modules:

ID Module Type TypeId RunAs 
Probe ProbeAction Microsoft.Windows.PowerShellPropertyBagTriggerOnlyProbe Default

Overrideable Parameters:

IDParameterTypeSelectorDisplay NameDescription
TimeoutSecondsint$Config/TimeoutSeconds$Timeout Seconds
UserPasswordstring$Config/UserPassword$UserPassword
UserCredentialstring$Config/UserCredential$UserCredential
SkuTypestring$Config/SkuType$SkuType

Source Code:

<ProbeActionModuleType ID="O365.SMP.O365ActiveUnitsCollection_V1.Script.Performance.Rule.ProbeActionModuleType" Accessibility="Internal" Batching="false" PassThrough="false">
<Configuration>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="TimeoutSeconds" type="xsd:integer"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="UserPassword" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="UserCredential" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="SkuType" type="xsd:string"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="TimeoutSeconds" Selector="$Config/TimeoutSeconds$" ParameterType="int"/>
<OverrideableParameter ID="UserPassword" Selector="$Config/UserPassword$" ParameterType="string"/>
<OverrideableParameter ID="UserCredential" Selector="$Config/UserCredential$" ParameterType="string"/>
<OverrideableParameter ID="SkuType" Selector="$Config/SkuType$" ParameterType="string"/>
</OverrideableParameters>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<ProbeAction ID="Probe" TypeID="Windows!Microsoft.Windows.PowerShellPropertyBagTriggerOnlyProbe">
<ScriptName>O365ActiveUnitsCollection_V1.ps1</ScriptName>
<ScriptBody><Script>
#=================================================================
#Created by: Taylour Blackwell
# Filename: O365_ConsumedUnitsCollection_v1.ps1
# Description: This collect the number of active licenses per O365 SKU for reporting.
# Updates: 8/2/17-TB- Added Units and Account Sku to property bag
# 8/7/17-BZ- Added WarnUnits to calculation to account for negatives
# 8/31/17-TB- Removed warn units/ Added 3rd state
# 9/26/17-TB-Added error checking from Tyson Paul
#=================================================================

#listing Parmeters
Param(
[parameter(Mandatory=$true)]
$UserCredential,
[parameter(Mandatory=$true)]
$UserPassword,
[parameter(Mandatory=$true)]
$SkuType
)

# loading the Azure AD powershell module
Import-Module MsOnline
Import-Module AzureAD

$api = new-object -comObject 'MOM.ScriptAPI'
$bag = $api.CreatePropertyBag()

#Converting the crednetials provided by the run as profile to a secure string so that they can be used to login.
$UserPassword = ConvertTo-SecureString -String $UserPassword -AsPlainText -Force
$Credential = New-Object -TypeName System.Management.Automation.PSCredential($UserCredential, $UserPassword)
$Service = Connect-AzureAD -Credential $Credential

#Initializing error checking
$Error.Clear()
$AllSKUs=@() #initialize so .Count property exists
$AcctSku=@() #initialize so .Count property exists

#Checking that we can pull the O365 SKU
$AllSKUs = Get-AzureADSubscribedSku
If (($Error) -or ($AllSKUs.Count -eq 0)) {
$api.LogScriptEvent('HealthService',55,2,"Problem getting O365 SKUs. $Error")
Exit
}
Else{
$AcctSku = ($AllSKUs | where {$_.SkuPartNumber -eq ($SkuType)})
If (($Error) -or ($AcctSku.Count -eq 0)) {
$api.LogScriptEvent('HealthService',55,2,"Problem getting O365 SKU. $Error")
Exit
}
}
#Checking to see how many licenses are consumed.
$ConUnits = $Acctsku.ConsumedUnits


#Adding Available units to property bag
$bag.AddValue('Consumed Units',"$Conunits")

$bag
</Script></ScriptBody>
<Parameters>
<Parameter>
<Name>UserPassword</Name>
<Value>$Config/UserPassword$</Value>
</Parameter>
<Parameter>
<Name>UserCredential</Name>
<Value>$Config/UserCredential$</Value>
</Parameter>
<Parameter>
<Name>SkuType</Name>
<Value>$Config/SkuType$</Value>
</Parameter>
</Parameters>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
<StrictErrorHandling>false</StrictErrorHandling>
</ProbeAction>
</MemberModules>
<Composition>
<Node ID="Probe"/>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.PropertyBagData</OutputType>
<TriggerOnly>true</TriggerOnly>
</ProbeActionModuleType>