gpt4 book ai didi

powershell - 导入模块不会多次运行

转载 作者:行者123 更新时间:2023-12-02 23:52:58 25 4
gpt4 key购买 nike

我有一个脚本应该复制另一个脚本并运行该模块,但是当我尝试多次运行它时,它就结束了,没有警告,没有输出/错误。

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

$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

关于powershell - 导入模块不会多次运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54363075/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com