RoyalServer.PowerShell.psm1
# # Script module for module 'RoyalServer.PowerShell' # Set-StrictMode -Version Latest $binarySubPath = 'netstandard2.0' $script:PSModule = $ExecutionContext.SessionState.Module $script:PSModuleRoot = $script:PSModule.ModuleBase $script:PSRoyalServer = 'RoyalServer.PowerShell.dll' $OneGetModulePath = Join-Path -Path $script:PSModuleRoot -ChildPath $script:PSRoyalServer $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:PSRoyalServer } $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 } } |