i've wrote script reads mail exchange inbox , writes sort of output (.txt files, folders, ..). working fine when run in powershell ise. problem starts when make bat (powershell.exe c:\script.ps1) , schedule bat in taskmanager. folders created, output files created empty. normally, content of global variable goes file, doesn't..
## global ### $body = '' $datereceived = '' $attachcont = '' function check() { dosomething $global:body = $mail.body.text } function write() { $body >> 'file.txt' }
i'm doing (look above). 'file.txt' made, it's empty. when 'write-host $body' above writing file, see nothing. there wrong global variable (i think?). note: when run in ise, content written, when start task in task manager, content isn't written.
is permission problem/a global variable problem?
got it. when don't define global variables first, works charm.
Comments
Post a Comment