From How to Write a PowerShell Module Manifest I learned that I can export all the variables in the module using VariablesToExport = '*'. However, after using it, I found that I could not export any variables.
After writing tests to confirm and reading more documentation, I didn't find the cause of the problem. I may have overlooked something important. What is going on here?
TestModule.psm1 excerpt:
0..9 | ForEach-Object { New-Variable -Name "v_$_" -Value $_ }
TestModule.psd1 excerpt:
@{ModuleVersion = '1.0';RootModule = 'TestModule.psm1';VariablesToExport = '*'}
TestModule.Tests.ps1:
# Confirm that the module has indeed been imported.
$ModuleName | Get-Module | ForEach-Object 'name' | Should -Be $ModuleName
# All variables do not exist.
0..9 | ForEach-Object { "variable:v_$_" | Test-Path | Should -BeFalse }