Passing a path directory to a function in PowerShell
<p>I am new to PS and I am trying to write a function which takes in parameters from a global variable. I want to pass a path name read from a .txt file into a function in the same script.</p>

<pre class="lang-powershell prettyprint-override"><code>function GetCorrectChildren ([string] $homepath,$min,$max,$row)
{
    #Testpoint 2
    write-host "homepath = $homepath"
    $ColItem = (Get-ChildItem $homepath |? {$_.PSIsContainer} | sort-object)
}

foreach ($homepath in (Get-Content $PSScriptRoot\homepath_short.txt))
{
    $freeSpace = [win32api]::GetDiskFreeSpace("$homepath").FreeBytesAvailable / 1073741824
    $totalSpace = [win32api]::GetDiskFreeSpace("$homepath").TotalNumberOfBytes / 1073741824 
    $percentageFreeSpace = $freeSpace / $totalSpace * 100

    if($freeSpace -lt $threshold)
    {
    #Testpoint 1
    write-host "homepath = $homepath"
    GetCorrectChildren ("$homepath",$min,$max,$OriRow)
}
</code></pre>

<p>For <code>#Testpoint 1</code>, it returns the path name correctly which is <code>\\C:\test1\test_a</code>. However in <code>#Testpoint 2</code> it returns <code>\\C:\test1\test_a 20 30 System.Object</code>.<br>
I don't understand what does the <code>20 30 System.Object</code> mean and where does it come from? Can some one shine some light on this? Thanks</p>