Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell-任务管理器-权限?_Powershell_Task_Exchangewebservices_Taskmanager - Fatal编程技术网

Powershell-任务管理器-权限?

Powershell-任务管理器-权限?,powershell,task,exchangewebservices,taskmanager,Powershell,Task,Exchangewebservices,Taskmanager,我编写了一个脚本,可以读取Exchange收件箱中的所有邮件,并写入所有类型的输出(.txt文件、文件夹等)。当我在powershell ISE中运行时,一切正常。当我制作bat(powershell.exe C:\script.ps1)并在TaskManager中计划bat时,问题就开始了。所有文件夹都已创建,输出文件已创建,但它们为空。通常,全局变量的内容会进入文件,但现在不会 ## Global ### $body = '' $dateReceived = '' $attachCont =

我编写了一个脚本,可以读取Exchange收件箱中的所有邮件,并写入所有类型的输出(.txt文件、文件夹等)。当我在powershell ISE中运行时,一切正常。当我制作bat(powershell.exe C:\script.ps1)并在TaskManager中计划bat时,问题就开始了。所有文件夹都已创建,输出文件已创建,但它们为空。通常,全局变量的内容会进入文件,但现在不会

## Global ###
$body = ''
$dateReceived = ''
$attachCont = ''

Function check() {
    DoSomething
    $Global:body = $mail.body.text
}

Function Write() {
    $body >> 'file.txt'
}
我正在做这样的事情(看上面)。'“File.txt”已生成,但为空。当我在写文件的上方执行“Write Host$body”时,我什么也看不到。所以全局变量有问题(我想是吧?)。注意:当我在ISE中运行它时,内容被写入,当我在task manager中启动任务时,内容没有被写入


这是权限问题还是全局变量问题?

明白了。当我不首先定义全局变量时,它就像一个符咒