powershell gotchas :- Use global variable / function when you have event in your code


Did you know that its a good idea to use global function and variables when you use event in your code.

Have a look at example below :-



You will not be able to call GetActiveQueueMessage function and your script just dies.

Key take from this is, if you have event, any variable or function you're referring to, please make sure its defined on global or script scope.

Otherwise, you pretty much get uninitialized or empty variable everywhere.







Comments

Popular posts from this blog

OpenCover code coverage for .Net Core

ionic2 cordova build android - Unable resolve gradle 2.2.3

Using Custom DLL with IronPython / Scripts