by moxman99 at 2013-02-19 11:14:25
Hello!by coderaven at 2013-02-21 07:30:36
I have a small script that will show a pop-up message when I call upon the Function for it. Here is the Function:Function Tester (){
$dataExtractedFolder = (Get-Location).Path
$result = [Microsoft.VisualBasic.Interaction]::MsgBox("The Report has been placed in $dataExtractedFolder",'OKOnly,SystemModal,Information', 'Report Generated!')
$result
}
Tester
When I insert this into the shell, it works fine. It will display the correct message like so:
[attachment=1]Messagepic.PNG[/attachment]
But when I save the function into a file like test.ps1 and try to execute by right-clicking and "Run with PowerShell", it shows me an error message that flashes this error message:
[attachment=0]Flash Error.PNG[/attachment]
Any suggestions on how to make message display while right clicking on the test.ps1 file?
Actually this is apart of problem that I am having when inserting the function into a bigger function that contains several functions. The message does not display at the end so I am drawing a conclusion to say that the reason why is above.
I have also tried this:Function Tester (){
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.VisualBasic.Interaction")
$dataExtractedFolder = (Get-Location).Path
$result = [Microsoft.VisualBasic.Interaction]::MsgBox("The Report has been placed in $dataExtractedFolder",'OKOnly,SystemModal,Information', 'Report Generated!')
$result
}
Tester
And This:Function Tester (){
[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
$dataExtractedFolder = (Get-Location).Path
$result = [Microsoft.VisualBasic.Interaction]::MsgBox("The Report has been placed in $dataExtractedFolder",'OKOnly,SystemModal,Information', 'Report Generated!')
$result
}
Tester
But still the same error.
Thanks in advanced!
I was able to get it working by loading all of Visual Basic.by moxman99 at 2013-02-21 09:16:40[void][System.Reflection.Assembly]]
Great! Thanks for this!
I cannot believe I did not try this beforeā¦