我有一个 powershell 脚本,可以解析文件并在检测到某种模式时发送电子邮件。我在函数中设置了电子邮件代码,当我从 ISE 运行它时一切正常,但我使用PS2EXE能够将脚本作为服务运行,但它无法识别函数“电子邮件”。我的代码看起来与此类似
#Do things |
foreach{
email($_)
}
function email($text){
#email $text
}
当我将其转换为 exe 并运行它时,我收到此错误:
The term 'email' is not recognized as teh name of a cmdlet, function, script file,
or operable program. Check the spelling of the name, or if a path was included,
verify that the path is correct and try again.