VMware.VumAutomation.Sdk.psm1
# # Script module for module 'VMware.VimAutomation.Sdk' # Set-StrictMode -Version Latest $binaryModuleFileName = 'VMware.VimAutomation.Sdk.psd1' # Set up some helper variables to make it easier to work with the module $PSModule = $ExecutionContext.SessionState.Module $PSModuleRoot = $PSModule.ModuleBase # Import the appropriate nested binary module based on the current PowerShell version $binaryModuleRoot = $PSModuleRoot if (($PSVersionTable.Keys -contains "PSEdition") -and ($PSVersionTable.PSEdition -ne 'Desktop')) { if ($PSVersionTable.PSVersion -lt "7.0.0") { $binaryModuleRoot = Join-Path -Path $PSModuleRoot -ChildPath 'netcoreapp2.0' } else { $binaryModuleRoot = Join-Path -Path $PSModuleRoot -ChildPath 'netcoreapp3.1' } } else { $binaryModuleRoot = Join-Path -Path $PSModuleRoot -ChildPath 'net45' } $binaryModulePath = Join-Path -Path $binaryModuleRoot -ChildPath $binaryModuleFileName $binaryModule = Import-Module -Name $binaryModulePath -PassThru # When the module is unloaded, remove the nested binary module that was loaded with it $PSModule.OnRemove = { Remove-Module -ModuleInfo $binaryModule } |