Skip to content

Commit cf506b8

Browse files
author
Dave Wyatt
committed
Added latest release dll to the Module folder, moved most of the code in PSLogging.psm1 inside a try block.
Compiled DLL in the Module\PSLogging folder is for convenience of people who want to use the module but can't compile it themselves.
1 parent ee0bb99 commit cf506b8

2 files changed

Lines changed: 11 additions & 11 deletions

File tree

Module/PSLogging/PSLogging.psm1

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Cmdlets and associated data types are defined in PowerShellLoggingModule.dll. This script file just handles attaching and detaching the PSHostIOInterceptor object.
1+
# Cmdlets and associated data types are defined in PowerShellLoggingModule.dll. This script file just handles attaching and detaching the HostIOInterceptor object.
22

33
$dllPath = Join-Path -Path $MyInvocation.MyCommand.ScriptBlock.Module.ModuleBase -ChildPath PowerShellLoggingModule.dll
44

@@ -8,27 +8,27 @@ try {
88
throw
99
}
1010

11-
# Attach the interceptor
12-
13-
$flags = [System.Reflection.BindingFlags]([System.Reflection.BindingFlags]::Instance -bor [System.Reflection.BindingFlags]::NonPublic)
11+
try {
12+
# Attach the interceptor
1413

15-
$uiRef = $Host.GetType().GetField('internalUIRef', $flags).GetValue($Host)
16-
$ui = $uiRef.GetType().GetProperty('Value', $flags).GetValue($uiRef, $null)
14+
$flags = [System.Reflection.BindingFlags]([System.Reflection.BindingFlags]::Instance -bor [System.Reflection.BindingFlags]::NonPublic)
1715

18-
$externalUIField = $ui.GetType().GetField('externalUI', $flags)
19-
$originalUI = $externalUIField.GetValue($ui)
16+
$uiRef = $Host.GetType().GetField('internalUIRef', $flags).GetValue($Host)
17+
$ui = $uiRef.GetType().GetProperty('Value', $flags).GetValue($uiRef, $null)
2018

21-
try {
19+
$externalUIField = $ui.GetType().GetField('externalUI', $flags)
20+
21+
$originalUI = $externalUIField.GetValue($ui)
22+
2223
$HostIOInterceptor = [PSLogging.HostIOInterceptor]::GetInterceptor()
2324
$HostIOInterceptor.HostUI = $originalUI
2425

2526
$externalUIField.SetValue($ui, $HostIOInterceptor)
26-
27+
2728
# Detach the interceptor when the module is removed.
2829
$MyInvocation.MyCommand.ScriptBlock.Module.OnRemove = {
2930
$script:externalUIField.SetValue($script:ui, $script:originalUI)
3031
}
3132
} catch {
3233
throw
3334
}
34-
18 KB
Binary file not shown.

0 commit comments

Comments
 (0)