using namespace を使い名前空間を指定すると、短い名前で型を参照することができる。
この事例は、System.Windows.Forms.MessageBoxのうち、 System.Windows.Forms を名前参照
させ、コーディングを短くしている。
using namespace System.Windows.Forms
Set-PSDebug -Strict
Add-Type -Assembly System.Windows.Forms
[MessageBox]::Show(
"メッセージ内容",
"タイトル",
[MessageBoxButtons]::YesNoCancel,
[MessageBoxIcon]::Stop,
[MessageBoxDefaultButton]::Button2)
PowerShell なかなかいいね。面白い


コメント