- >> Platform: V5 64Bit (STA)
- ERROR: New-Object : Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 80080005
- ERROR: Server execution failed (Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE)).
- PS1_Sandbox.ps1 (6, 8): ERROR: At Line: 6 char: 8
- ERROR: + $ol = (New-Object -comobject Outlook.Application)
- ERROR: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ERROR: + CategoryInfo : ResourceUnavailable: (:) [New-Object], COMException
- ERROR: + FullyQualifiedErrorId : NoCOMClassIdentified,Microsoft.PowerShell.Commands.NewObjectCommand
- ERROR:
I'm new to PowerShell Studio but I have been using PowerShell for years with other IDEs, originally PowerGui and then VS Code. I'm not a fan of the VS Code environment which is why I switched to PowerShell Studio. I'm sure there are nuances I'm oblivious to which is why I thought I'd seek help here.
I have a process that connects to MS Outlook to search messages for keywords for audit purposes. "This" is the first time running the process in PS Studio, and I have encountered an error that does not happen in VS Code or the PowerShell ISE. When I run the code below, at the "New-Object" line in PS Studio I get the following error message:
- [void](Add-Type -assembly "Microsoft.Office.Interop.Outlook")
- $ol = (New-Object -comobject Outlook.Application)
When this identical code is executed in VS Code it works as expected with no no exceptions. I guess my question is, is there something I need to define in PS Studio, such as adding a reference library (as in Visual Studio C# "References" - not a using statement)? I haven't found anything but I'm new to the IDE so I may be missing something. Or, is there additional PS1, or PS1 I am unaware of needed? I wouldn't think so of the latter as it works in VS Code and have found nothing to indicate otherwise with Googling (StackOverflow, etc etc), but I very well could be missing something.
I would appreciate any feedback and advice, and thank you!!!
Environment specs:
Powershell Studio v5.8.207
VSCode 1.78.0
Windows 10 Enterprise v21H2 OSBuild 19044.2728