2017-10-19 109 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

回答