How can i get the url of a website with powershell and look all the links of this page ( crawl)
<p>Hi I`m trying to make a spider crawl in powershell. 
it make a list of all the urls in a web and for each url it look all the urls and so on according to depth</p>

<p>I have this</p>

<pre><code>Function Get-DepthURL ($url, $depth){
$count = 0
Write-Host “URL”  $url
$Test = Invoke-WebRequest -URI $url
[int]$top=[int]$depth
$link=$Test.Links | Foreach {$_.href 
    if ($top -ne 0){
    [int]$top=[int]$top-[int]1
Get-DepthURL ("$link", $top)
}
$count = [int]$count+[int]1
}
Write-Host “Number of Hrefs on URL=”  $count
}
</code></pre>

<p>the problem is when i try to recursivly in on another url </p>

<pre><code>Get-DepthURL ("$link", $top)
</code></pre>

<p>the variable $link get the entire web and i want just the url that i am looking.</p>

<p>Thanks in advance</p>