我有一個powershell腳本,它解析一個文件,併發送一封電子郵件,如果它檢測到某種模式。我在一個函數中設置了電子郵件代碼,當我從ISE運行它時,它一切正常,但我使用PS2EXE能夠將腳本作爲服務運行,但它不能識別函數「email」。我的代碼類似於此Powershell腳本不能識別我的功能
#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.
感謝它現在的作品! – laitha0