RoyalDocument.PowerShell.psm1
# # Script module for module 'RoyalDocument.PowerShell' # Set-StrictMode -Version Latest $isCore = ($PSVersionTable.Keys -contains "PSEdition") -and ($PSVersionTable.PSEdition -ne 'Desktop') $binarySubPath = 'net47' if ($isCore) { $binarySubPath = 'netcoreapp3.1' } $script:PSModule = $ExecutionContext.SessionState.Module $script:PSModuleRoot = $script:PSModule.ModuleBase $script:PSRoyalDoc = 'RoyalDocument.PowerShell.dll' $OneGetModulePath = Join-Path -Path $script:PSModuleRoot -ChildPath $script:PSRoyalDoc $binaryModuleRoot = $script:PSModuleRoot if (-not(Test-Path -Path $OneGetModulePath)) { # Import the appropriate nested binary module based on the current PowerShell version $binaryModuleRoot = Join-Path -Path $script:PSModuleRoot -ChildPath $binarySubPath $OneGetModulePath = Join-Path -Path $binaryModuleRoot -ChildPath $script:PSRoyalDoc } $OneGetModule = Import-Module -Name $OneGetModulePath -PassThru # When the module is unloaded, remove the nested binary module that was loaded with it if($OneGetModule) { $script:PSModule.OnRemove = { Remove-Module -ModuleInfo $OneGetModule } } |