After help from some of SO esteemed members I reached to the point where I can run below code. But it happens that this script runs out in middle. **The ERROR I get is pasted at last.**

TILL NOW : I re-started my system number of times just to make sure it isn't some system problem but no luck. 

Please note I added following three lines in code, again to make sure that it is something because of some IE. 

```
**# try few things 
$result = $null
$ie.quit
get-process iexplore | stop-process**

```

CODE STARTS HERE :

```
 $controls   = Get-Content ("d:\users\yarora\desktop\hkd1000.txt")
    Add-Type -AssemblyName 'System.Web'

    Function getStringMatch
    {

       Foreach ($control In $controls)
        {
         $ie = New-Object -COMObject InternetExplorer.Application

    #for testing purpose
    $control

    #encode the special characters in URL like %,& etc.

    $controlUri = [System.Web.HttpUtility]::UrlEncode($control)
    $site = $ie.Navigate("https://www.xxxy.com/search/all?name=$controlUri")

    #$ie.ReadyState

        while ($ie.Busy){ sleep -Milliseconds 100 }

            $link = $null
            $link = $ie.Document.get_links() | where-object {if ($_.innerText){$_.innerText.contains($control)}}
            $link.click()

        while ($ie.Busy){ sleep -Milliseconds 100 }

    [regex]$regex = 
    @'
    (?s).+?<A href="/generics/.*?">(.*?)</A>
    '@

    $result = $regex.Matches($ie.Document.body.outerHTML) |
    foreach {
              [PSCustomObject]@{
              Name = $control
              Saltname = $_.Groups[1].value 
             }

    }

    $result | out-file d:\result.txt -append 

    # try few things 
    $result = $null
    $ie.quit
    get-process iexplore | stop-process

    }
    }
    getStringMatch

```

**ERROR** 

New-Object : Retrieving the COM class factory for component with CLSID {0002DF01-0000-0000-C000-000000000046} failed
 due to the following error: 800706bf The remote procedure call failed and did not execute. (Exception from HRESULT:
 0x800706BF).
 At D:\script.ps1:22 char:12
 + $ie = New-Object -COMObject InternetExplorer.Application
 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 + CategoryInfo : ResourceUnavailable: (:) [New-Object], COMException
 + FullyQualifiedErrorId : NoCOMClassIdentified,Microsoft.PowerShell.Commands.NewObjectCommand

**UPDATE**
As per suggestion from Micky, I placed -COMobject out of Foreach loop. But the script still errors out after few loops :

```
You cannot call a method on a null-valued expression.
At D:\desktop\hkdforsalt1000.ps1:41 char:9
+         $link.click()
+         ~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

```