NCache.OpenSource.psm1
|
# # Script module for NCache.OpenSource # # Get current module info $script:PSModule = $ExecutionContext.SessionState.Module $script:PSModuleRoot = $script:PSModule.ModuleBase # PowerShell 7+ (Core) loads the .NET Core build, Windows PowerShell 5.1 (Desktop) the .NET Framework build $isCore = ($PSVersionTable.Keys -contains "PSEdition") -and ($PSVersionTable.PSEdition -ne 'Desktop') $binarySubPath = if ($isCore) { 'core' } else { 'framework' } # Name of DLL $script:PSPkgMgmt = 'ncacheps.dll' # DLL is in the core or framework folder under the PSM1 $PSBinaryModulePath = Join-Path -Path (Join-Path -Path $script:PSModuleRoot -ChildPath $binarySubPath) -ChildPath $script:PSPkgMgmt # Import the DLL $PSBinaryModule = Import-Module -Name $PSBinaryModulePath -PassThru -Force # Auto-remove binary when module is unloaded if ($PSBinaryModule) { $script:PSModule.OnRemove = { Remove-Module -ModuleInfo $PSBinaryModule } } |