1

I'm getting the following error when I run a script. It takes a few loops before it starts popping up.

New-Object : Creating an instance of the COM component with CLSID 
{0002DF01-0000-0000-C000-000000000046} from the IClassFactory failed due to the 
following error: 80004005 Unspecified error (Exception from HRESULT: 0x80004005 
(E_FAIL)).
At C:\Users\Script.ps1:210 
char:13
+       $ie = New-Object -Com "InternetExplorer.Application"
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (:) [New-Object], COMException
    + FullyQualifiedErrorId : NoCOMClassIdentified,Microsoft.PowerShell.Commands.NewObjectCommand

1 Answer 1

2

If you are constantly creating a new Internet Explorer Com object in a loop without destroying it when you are finished with it, you are bound to get the ResourceUnavailable error at some point.

Put this in your code (loop) when you are done using the object to clear it from memory:

$ie.Quit()
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($ie) | Out-Null
[System.GC]::Collect()
[System.GC]::WaitForPendingFinalizers()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.