When you develop PowerShell scripts in the PowerShell ISE editor, you should run the final tests in a clean environment, making sure that no leftover variables or functions from previous runs interfere.
The easiest way to create a completely fresh testing environment is this: choose the menu File, then "New PowerShell Tab". This gets you a new tab, and this tab actually represents a completely new PowerShell host. Perfect for testing!