Scope of variables inside form scripts - by AARUNK

Status : 


Sign in
to vote
ID 775034 Comments
Status Active Workarounds
Type Bug Repros 1
Opened 12/22/2012 11:26:32 PM
Access Restriction Public


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?

#TODO: Place custom script here
Import-Module -name .\functions.ps1 -Global
Import-Module -name .\customscript.ps1 -Global

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
Sign in to post a comment.