Inspired by “Leon Bambrick” blog, I’ve decided to start a Category on my blog wherein I’ll be posting small stuff that I learn that never get a chance to land up on a blog post. It can be a Tip, single line of code or concept, anything that is worth sharing.
TODAY I LEARNED : How to identify variables in a script open Powershell ISE ?
For a small code its a piece of cake, but to identify all variables in hundreds of lines of code is Humongous task.
Well it was easy than I expected, use the Powershell parser to tokenize (A programming token is the basic component of source code, like variables, operators and separators)all content of the current open tab of ISE, then filter out variables. BOOM! here you go with the variables.
I’ve wrapped this in a function and added functionality to identify variables in all open ISE.
You can find the function on my Github Repository – http://github.com/PrateekKumarSingh/Today.I.Learned