MessageBox

While 関数内で使うと、値をダイアログで表示し、While を一時停止できます。

Let([

Arguments="

$Job=Start-Job {

start-sleep -Milliseconds 0;

add-type -AssemblyName microsoft.VisualBasic;

add-type -AssemblyName System.Windows.Forms;

$ps = Get-Process | Where-Object {$_.Name -eq 'powershell'};

foreach($process in $ps){

[Microsoft.VisualBasic.Interaction]::AppActivate($process.ID);

if($process.MainWindowTitle -ne '') {

if($process.MainWindowTitle -match \"{CAPTION}\") {

[Microsoft.VisualBasic.Interaction]::AppActivate($process.ID);

}

}

}

};

Add-Type -AssemblyName System.Windows.Forms;

$text = \"{TEXT}\";

$caption = \"{CAPTION}\";

$buttonsType = \"YesNo\";

$Form = New-Object System.Windows.Forms.Form;

$result = [System.Windows.Forms.MessageBox]::Show($text, $caption, $buttonsType);

$result;"

;$ps =

Substitute ( Arguments ;

["{TEXT}"; Substitute ( TEXT ; ["`" ; "``"] ; ["\"" ; "`\""]; ["$" ; "`$"] )]

; ["{CAPTION}"; Substitute ( CAPTION ; ["`" ; "``"] ; ["\"" ; "`\""]; ["$" ; "`$"] )]

)


];

SMPS_Exe( $ps )

)