Home Dashboard Directory Help
Search

Scope of variables inside form scripts by AARUNK


Status: 

Active


4
0
Sign in
to vote
Type: Bug
ID: 775034
Opened: 12/22/2012 11:26:32 PM
Access Restriction: Public
0
Workaround(s)
view
1
User(s) can reproduce this bug

Description

On form load, I am importing the module from two scripts functions.ps1 and and customscript.ps1.
In powershell version 2.0, it works with no issues.

However in powershell 3.0, I am getting error " 'is_not_empty' is not recognized as the name of a cmdlet". "is_not_empty" is a function, I defined in functions.ps1.
I did some debugging, and found that in version 3.0, any modules or variables that are defined/Initialized under "{ }" can not be accessed out-side of it. However, this works fine in powershell ver 2.0.

I want to know, whether it's a bug in version 3.0, or is it a expected behaviour?


$handler_form1_Load=
{
#TODO: Place custom script here
Import-Module -name .\functions.ps1 -Global
Import-Module -name .\customscript.ps1 -Global
}
.....
.....
.....
$form1.add_Load($handler_form1_Load)

=======================================
is_not_empty : The term 'is_not_empty' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\MyInstalls\AisCustomBoltz\AisCustomBoltz.ps1:127 char:5
+ if (is_not_empty $label2.Text $richTextBox1.Text) {
+     ~~~~~~~~~~~~
    + CategoryInfo         : ObjectNotFound: (is_not_empty:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
Details
Sign in to post a comment.
Sign in to post a workaround.