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
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()
User contributions licensed under CC BY-SA 3.0