[英]Suppress output created by PowerShell New-Object
Suppress PowerShell output messages new outlook application object is created? 抑制PowerShell输出消息是否创建了新的Outlook应用程序对象?
$outlook = New-Object -ComObject outlook.application
$outlookItem = $outlook.CreateItem("olMailItem")
I already tried using these approaches. 我已经尝试过使用这些方法。 They did not work:
他们没有工作:
$outlook = New-Object -ComObject outlook.application > $Null
$outlook = New-Object -ComObject outlook.application |Out-Null
($outlook = New-Object -ComObject outlook.application) |Out-Null
These are the output message that I don't want them on the screen: 这些是我不希望它们出现在屏幕上的输出消息:
Application : Microsoft.Office.Interop.Outlook.ApplicationClass
Class : 5
...
...
@boxdog, thanks for pointing it out. @boxdog,谢谢你指出来。 After many break points, I noticed the output is produced by Attachments.Add() method.
在多个断点之后,我注意到输出是由Attachments.Add()方法产生的。 It is resolved using >$null.
它使用> $ null解析。
$outlookItem.Attachments.Add("fileName.txt") > $null
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.