Skip to content

Commit

Permalink
Existing unit tests are now green.
Browse files Browse the repository at this point in the history
Still need to start adding new unit tests.
  • Loading branch information
RandomNoun7 committed Apr 7, 2020
1 parent 792cd12 commit d5f7cf6
Show file tree
Hide file tree
Showing 2 changed files with 199 additions and 80 deletions.
81 changes: 41 additions & 40 deletions source/DSCResources/DSC_xServiceResource/DSC_xServiceResource.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -2145,57 +2145,58 @@ function Get-ServiceFailureActions {
$Service
)
process {
$registryData = Get-Item -Path HKLM:\SYSTEM\CurrentControlSet\Services\$service

$failureActions = [PSCustomObject]@{
resetPeriodSeconds = $null
hasRebootMessage = $null
hasFailureCommand = $null
failureActionCount = $null
failureCommand = $null
rebootMessage = $null
actionsCollection = $null
$FailureActionsOnNonCrashFailures = $false
}
if($registryData = Get-Item -Path HKLM:\SYSTEM\CurrentControlSet\Services\$service -ErrorAction SilentlyContinue)
{
$failureActions = [PSCustomObject]@{
resetPeriodSeconds = $null
hasRebootMessage = $null
hasFailureCommand = $null
failureActionCount = $null
failureCommand = $null
rebootMessage = $null
actionsCollection = $null
FailureActionsOnNonCrashFailures = $false
}

if($registryData.GetvalueNames() -match 'FailureCommand') {
$failureActions.failureCommand = $registryData.GetValue('FailureCommand')
}
if($registryData.GetvalueNames() -match 'FailureCommand') {
$failureActions.failureCommand = $registryData.GetValue('FailureCommand')
}

if($registryData.GetValueNames() -match 'RebootMessage') {
$failureActions.rebootMessage = $registryData.GetValue('RebootMessage')
}
if($registryData.GetValueNames() -match 'RebootMessage') {
$failureActions.rebootMessage = $registryData.GetValue('RebootMessage')
}

if($registryData.GetvalueNames() -match 'FailureActionsOnNonCrashFailures') {
$failureActions.FailureActionsOnNonCrashFailures = [System.Boolean]$registryData.GetValue('FailureActionsOnNonCrashFailures')
}
if($registryData.GetvalueNames() -match 'FailureActionsOnNonCrashFailures') {
$failureActions.FailureActionsOnNonCrashFailures = [System.Boolean]$registryData.GetValue('FailureActionsOnNonCrashFailures')
}

if($registryData.GetValueNames() -match 'FailureActions')
{
$failureActionsBinaryData = $registryData.GetValue('FailureActions')
if($registryData.GetValueNames() -match 'FailureActions')
{
$failureActionsBinaryData = $registryData.GetValue('FailureActions')

# The first four bytes represent the Reset Period.
$failureActions.resetPeriodSeconds = Get-FailureActionsProperty -PropertyName ResetPeriodSeconds -Bytes $failureActionsBinaryData
# The first four bytes represent the Reset Period.
$failureActions.resetPeriodSeconds = Get-FailureActionsProperty -PropertyName ResetPeriodSeconds -Bytes $failureActionsBinaryData

# Next four bytes indicate the presence of a reboot message in case one of the chosen failure actions is
# SC_ACTION_REBOOT. The actual value of the message is stored in the 'RebootMessage' property
$failureActions.hasRebootMessage = Get-FailureActionsProperty -PropertyName HasRebootMsg -Bytes $failureActionsBinaryData
# Next four bytes indicate the presence of a reboot message in case one of the chosen failure actions is
# SC_ACTION_REBOOT. The actual value of the message is stored in the 'RebootMessage' property
$failureActions.hasRebootMessage = Get-FailureActionsProperty -PropertyName HasRebootMsg -Bytes $failureActionsBinaryData

# The next four bytes indicate whether a failure action run command exists. This command
# would be run in the case one of the failure actions chosen is SC_ACTION_RUN_COMMAND
# If this value is true then the actual command string is stored in the 'FailureCommand' property.
$failureActions.hasFailureCommand = Get-FailureActionsProperty -PropertyName HasFailureCommand -Bytes $failureActionsBinaryData
# The next four bytes indicate whether a failure action run command exists. This command
# would be run in the case one of the failure actions chosen is SC_ACTION_RUN_COMMAND
# If this value is true then the actual command string is stored in the 'FailureCommand' property.
$failureActions.hasFailureCommand = Get-FailureActionsProperty -PropertyName HasFailureCommand -Bytes $failureActionsBinaryData

# These four bytes give the count of how many reboot failure actions have been defined.
$failureActions.failureActionCount = Get-FailureActionsProperty -PropertyName FailureActionCount -Bytes $failureActionsBinaryData
# These four bytes give the count of how many reboot failure actions have been defined.
$failureActions.failureActionCount = Get-FailureActionsProperty -PropertyName FailureActionCount -Bytes $failureActionsBinaryData

if($failureActions.failureActionCount -gt 0)
{
$failureActions.ActionsCollection = Get-FailureActionCollection -Bytes $failureActionsBinaryData -ActionsCount $failureActions.failureActionCount
if($failureActions.failureActionCount -gt 0)
{
$failureActions.ActionsCollection = Get-FailureActionCollection -Bytes $failureActionsBinaryData -ActionsCount $failureActions.failureActionCount
}
}
}

$failureActions
$failureActions
}
}
}

Expand Down
Loading

0 comments on commit d5f7cf6

Please sign in to comment.