Working with Office COM Objects Using PowerShell on a Server

I was recently working on a PowerShell script that needed to write to an Excel spreadsheet on a server. I installed Office, but it wasn’t working. I had to Google for a long time to find the answer, so I figured I’d repost it. In order for PowerShell to be able to work with the COM objects there needs to be a specific directory that exists. This varies depending on whether you’re running 32-bit or 64-bit version of office. The directory is:

  • 32-bit – C:\Windows\SysWOW64\config\systemprofile\desktop
  • 64-bit – C:\Windows\System32\config\systemprofile\desktop

If that directory doesn’t exist, you’ll just need to create it.

Leave a Reply

Your email address will not be published. Required fields are marked *