将此代码转换为One-Liner?

时间:2017-10-19 11:50:46

标签: powershell

您是否知道如何将以下代码转换为单行代码?我已经看到它用类似的代码完成了。这样做的原因,我想远程执行。

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)

1 个答案:

答案 0 :(得分:0)

查看将代码汇编到scriptblock中,然后将其传递给远程会话。

参考:http://www.padisetty.com/2014/05/all-about-powershell-scriptblock.html