Skip to content

Commit

Permalink
Fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
mkht committed Sep 15, 2022
1 parent 7497663 commit 78e45b3
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions DSCResources/cApplication/cApplication.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ function Test-TargetResource {
ProductId = $ProductId
InstalledCheckFilePath = $InstalledCheckFilePath
Fuzzy = $Fuzzy
LogLevel = $LogLevel
}

$ProgramInfo = Get-TargetResource @GetParam -ErrorAction Stop
Expand Down Expand Up @@ -1034,22 +1035,33 @@ function Write-MyVerbose {
)

begin {
$WriteVerboseParams = [System.Collections.Generic.Dictionary[[String], [Object]]]::new($PSBoundParameters)
$null = $WriteVerboseParams.Remove('LogLevel')
$wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Write-Verbose', [System.Management.Automation.CommandTypes]::Cmdlet)
$scriptCmd = { & $wrappedCmd @WriteVerboseParams }
$steppablePipeline = $scriptCmd.GetSteppablePipeline($myInvocation.CommandOrigin)
$steppablePipeline.Begin($PSCmdlet)
if (($null -eq $global:GlobalLogLevel) -or ($LogLevel -le $global:GlobalLogLevel)) {
$ShouldInvoke = $true
}
else {
$ShouldInvoke = $false
}

if ($ShouldInvoke) {
$WriteVerboseParams = [System.Collections.Generic.Dictionary[[String], [Object]]]::new($PSBoundParameters)
$null = $WriteVerboseParams.Remove('LogLevel')
$wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Write-Verbose', [System.Management.Automation.CommandTypes]::Cmdlet)
$scriptCmd = { & $wrappedCmd @WriteVerboseParams }
$steppablePipeline = $scriptCmd.GetSteppablePipeline($myInvocation.CommandOrigin)
$steppablePipeline.Begin($PSCmdlet)
}
}

process {
if (($null -eq $global:GlobalLogLevel) -or ($LogLevel -le $global:GlobalLogLevel)) {
if ($ShouldInvoke) {
$steppablePipeline.Process($_)
}
}

end {
$steppablePipeline.End()
if ($ShouldInvoke) {
$steppablePipeline.End()
}
}
}

Expand Down

0 comments on commit 78e45b3

Please sign in to comment.