Same Problem. I have a simple function in a module:
NumberOfFoldersInDir($pathToDir, $_isRecursive)
This module is used by a class within another module. I return a value, depending on the optional bool param _isRecursive:
if($_isRecursive) { return (1) }; else { return (2) }
1) (Get-ChildItem -Path $pathToDir -Directory -Recurse).Count
2) (Get-ChildItem -Path $path -Directory).Count
In the module, when I save to a variable and write-host, values are:
1) == 2
2) == 1
In my class, in the other module:
1) $returnVal = NumberOfFoldersInDir $path $true == 2
Checks Out.
2) $returnValue = NumberOfFoldersInDir $path $false == 3
WTF?