2016-09-23 68 views
0

我想從使用PowerShell腳本的在線交流2016獲取一些信息。在這裏我使用這個腳本如何禁止Exchange的ExportedCommands輸出powershell腳本輸出

$UserCredential = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $userName, $(convertto-securestring $Password -asplaintext -force) 
$ExchangeSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://outlook.office365.com/powershell-liveid/" -Credential $UserCredential -Authentication "Basic" -AllowRedirection 
Import-PSSession $ExchangeSession -DisableNameChecking 

和我得到以下的輸出:

ModuleType版本名稱ExportedCommands
---------- ------- ---- ----------------
腳本1.0 tmp_avadkvxn.tjc獲取-MailboxUsageReport

我的問題是, 我不想在這上面的消息我輸出。如何抑制這一點?我只想要確切的輸出。在這裏我沒有提到我用過的命令。試圖導入其在控制檯給這個信息的消息,如何提前抑制這種

感謝,

了Arul

+0

任何一個可以幫我請 – Arulmurugan

+0

'進口PSSession'返回模塊對象。重定向該命令的結果應該足夠了,例如, '$ null = Import-PSSession ...' – BartekB

回答

0

嘗試如下使用導入命令的會話。

這將工作:

$null = Import-PSSession