首页 > 解决方案 > Powershell 脚本问题

问题描述

我想弹出在 powershell 中执行的输出这是我的 powershell 的示例输出

在图片中,您可以看到“GetDirectories is not reconized”错误。

如果错误条件在 powershell 输出中匹配意味着我想弹出一个显示错误“GetDirectories is not reconized”

请建议powershell脚本。

标签: powershell

解决方案


Try {
        GetDirectories -ErrorAction Stop
    }



Catch {

        Add-Type -AssemblyName PresentationCore,PresentationFramework

        $ButtonType = [System.Windows.MessageBoxButton]::OK
    
        $MessageboxTitle = "Test pop-up message title"
        $Messageboxbody = "GetDirectories is not reconized"
        $MessageIcon = [System.Windows.MessageBoxImage]::Warning
    
        [System.Windows.MessageBox]::Show($Messageboxbody,$MessageboxTitle,$ButtonType,$messageicon)

     } 

推荐阅读