title: Powershell cannot create Outlook COM object from Command Prompt
body: <p>I have a script used to send mails via Microsoft Outlook from command prompt. This works fine if I run it from inside PowerShell or ISE console. But when I tried to execute same from classic Windows Command prompt (cmd.exe) even with Admin privileges, it was unable to create Outlook COM object. Here is the line to create COM object:</p>
  
  <pre><code>$objOutLook = New-Object -com Outlook.Application
  </code></pre>
  
  <p>This is how I call my script from cmd.exe (Administrative privileges) :</p>
  
  <blockquote>
    <p>D:>powershell D:\MiscBuildTasks.ps1 -sendmail -MailTo 'farrukh@MyMail.com'</p>
  </blockquote>
  
  <p>and here is the error log:</p>
  
  <blockquote>
    <p>New-Object : Retrieving the COM class factory for component with CLSID
    {0006F03A-0000-0000-C000-000000000046} failed due to the following
    error: 80080005 Server execution failed (Exception from HRESULT:
    0x80080005 (CO_E_SERVER_EXEC_FAILURE)). 
    At D:\MiscBuildTasks.ps1:81 char:12
    + <strong>$Outlook = New-Object -ComObject Outlook.Application</strong>
    +            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : ResourceUnavailable: (:) [New-Object], COMException
        + FullyQualifiedErrorId : NoCOMClassIdentified,Microsoft.PowerShell.Commands.NewObjectCommand</p>
  </blockquote>
  
  <p><strong>How can I make it work from cmd.exe (Windows Command Prompt)??</strong>
  Thanks</p>