2017-10-19 123 views
-3

大家知道如何將下面的代碼轉換爲一行代碼?我已經看到它用類似的代碼完成。這樣做的原因,我想遠程執行。將此代碼轉換爲One-Liner?

Add-Type -AssemblyName PresentationCore,PresentationFramework 
$ButtonType = [System.Windows.MessageBoxButton]::YesNoCancel 
$MessageIcon = [System.Windows.MessageBoxImage]::Warning 
$MessageBody = "!Attention! Our Network is having Connectivity Issues. NO ETA on when it's going to be fixed. Sorry for the inconvinience. Thank you " 
$MessageTitle = "Network Connectivity Issue" 

$Result = [System.Windows.MessageBox]::Show($MessageBody,$MessageTitle,$ButtonType,$MessageIcon) 
+3

爲了執行遠程代碼可以使用[調用指令(https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/invoke-command ?view = powershell-5.1),無論代碼的長度/大小如何。 – DarkLite1

+0

@ DarkLite1我可能想太多了,我真的不知道它是如何完成的。你想照看我嗎?那樣,我可以學習如何做到這一點,而不是得到一個免費的答案? – Abesaurous

+3

@Aaeaurous沒有理由讓這是一個單線程,尤其是當文本大部分長度時,不要將它全部包裝在'Invoke-Command'中,或者將它放在'.ps1'中並運行它。 。 – ConnorLSW

回答