From 3e8df622eeb17c12f5379915542ea7ffe3114e87 Mon Sep 17 00:00:00 2001 From: Amber Erickson Date: Tue, 24 Mar 2020 01:34:47 -0700 Subject: [PATCH] Add PSModule.psm1 --- src/PSModule.psm1 | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/PSModule.psm1 diff --git a/src/PSModule.psm1 b/src/PSModule.psm1 new file mode 100644 index 000000000..5b508ac3f --- /dev/null +++ b/src/PSModule.psm1 @@ -0,0 +1,32 @@ +# +# Script module for module 'PowerShellGet' +# +Set-StrictMode -Version Latest + +# Summary: PowerShellGet is supported on Windows PowerShell 5.0 or later and PowerShellCore + +# Set up some helper variables to make it easier to work with the module +$script:PSModule = $ExecutionContext.SessionState.Module +$script:PSModuleRoot = $script:PSModule.ModuleBase + +$script:PSGet = 'PowerShellGet.dll' + + +# Try to import the PowerShellGet assemblies +$PSGetModulePath = Join-Path -Path $script:PSModuleRoot -ChildPath $script:PSGet + + +if(-not (Test-Path -Path $PSGetModulePath)) +{ + # Should not happen +} + +$PSGetModule = Import-Module -Name $PSGetModulePath -PassThru + + +if($PSGetModule) +{ + $script:PSModule.OnRemove = { + Remove-Module -ModuleInfo $PSGetModule + } +}