我的 PowerShell 脚本有问题。我正在尝试检查收件箱中收到的电子邮件。当一封电子邮件到达收件箱时,脚本会调用一个批处理文件,该文件将收到的电子邮件的一些数据保存在数据库中。当我只使用字符串(测试)调用批处理文件时,一切正常,但是当我尝试使用需要保存的真实信息更改参数之一时,不会调用批处理文件。这是我的代码。
$MailboxName = "[my address]"
...
Microsoft.Exchange.WebServices.Data.StreamingSubscriptionConnection($service, 30);
$stmConnection.AddSubscription($stmsubscription)
Register-ObjectEvent -inputObject $stmConnection -eventName "OnNotificationEvent" -Action {
foreach($notEvent in $event.SourceEventArgs.Events){
[String]$itmId = $notEvent.ItemId.UniqueId.ToString()
$message = [Microsoft.Exchange.WebServices.Data.EmailMessage]::Bind($event.MessageData,$itmId)
$name=$message.sender.Name.ToString()
$arguments= "param1" , "param2" ,"param3" , "param4" , "param5" , "param6" ,"param7" , 1
$arguments + (Get-Date) | Out-File c:\temp\log2.txt -Append
Start-Process "spiderT.bat" $arguments
}
} -MessageData $service
Register-ObjectEvent -inputObject $stmConnection -eventName "OnDisconnect" -Action {$event.MessageData.Open()} -MessageData $stmConnection
...
...
现在,如果我改变
$arguments= "param1", "param2" ,"param3" , "param4" , "param5" , "param6" ,"param7" , 1
经过
$arguments= $name , "param2" ,"param3" , "param4" , "param5" , "param6" ,"param7" , 1
看起来没有调用批处理文件(我看到的最后一件事是日志,但不是我在数据库中的数据)。怎么了?