Skip to content

Commit aba9e40

Browse files
committed
Fix module reloading where cmdlets are unloaded but types not
1 parent 2e8ae31 commit aba9e40

1 file changed

Lines changed: 4 additions & 16 deletions

File tree

PSCompatibilityCollector/PSCompatibilityCollector.psm1

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,11 @@
22
# Licensed under the MIT License.
33

44
# Add the relevant binary module
5-
try
5+
if ($PSVersionTable.PSVersion.Major -ge 6)
66
{
7-
$null = [Microsoft.PowerShell.CrossCompatibility.Commands.NewPSCompatibilityProfileCommand]
8-
$compatibilityLoaded = $true
7+
Import-Module ([System.IO.Path]::Combine($PSScriptRoot, 'netstandard2.0', 'Microsoft.PowerShell.CrossCompatibility.dll'))
98
}
10-
catch
9+
else
1110
{
12-
$compatibilityLoaded = $false
13-
}
14-
if (-not $compatibilityLoaded)
15-
{
16-
if ($PSVersionTable.PSVersion.Major -ge 6)
17-
{
18-
Import-Module ([System.IO.Path]::Combine($PSScriptRoot, 'netstandard2.0', 'Microsoft.PowerShell.CrossCompatibility.dll'))
19-
}
20-
else
21-
{
22-
Import-Module ([System.IO.Path]::Combine($PSScriptRoot, 'net452', 'Microsoft.PowerShell.CrossCompatibility.dll'))
23-
}
11+
Import-Module ([System.IO.Path]::Combine($PSScriptRoot, 'net452', 'Microsoft.PowerShell.CrossCompatibility.dll'))
2412
}

0 commit comments

Comments
 (0)