' **************************************************
' PowerShellの実行(Execコマンド使用バージョン)
' **************************************************
Private Function ExecPowerShell(cmdStr As String) As String
' WshShellオブジェクト
Dim oExec As Object
' Execコマンドで実行する
Set oExec = CreateObject("Wscript.shell").Exec("powershell -ExecutionPolicy Unrestricted -File " + cmdStr)
' ジョブが実行中(0)の間は、スリープしながら完了(1)まで待つ
Do While oExec.Status = 0
' 100ミリ秒
Sleep 100
Loop
' 標準出力取得
ExecPowerShell = oExec.StdOut.ReadAll
End Function