导入模块 运行 不超过一次

Import-module doesn't run more than once

我有一个脚本应该复制另一个脚本和 运行 模块,但是当我尝试 运行 这不止一次时,它只是结束,没有警告,没有 out-put/errors.

我一直在努力导入模块来帮助我的脚本 运行 更好并简化使用。

$Script:Es = $PSScriptRoot + "\" + "Main Script.psm1"
$Script:Ma32 = "C:\Temp\Scripts2"
$Script:E2 = "\Main Script.psm1"
$Script:E3 = $Ma32 + $E2

Function Get-Check {
    if ( -Not (Test-Path -Path $Ma32 ) ) {
        New-Item -ItemType directory -Path $Ma32 |out-null
    }
}

Function Get-Run {
    copy-item $Es $Ma32
    Import-Module $E3 
}

Function St {
    Get-Check
    Get-Run
}

St

感谢大家的回答,使用 -force 解决了问题。

Import-Module $E3 -force