Powershell Excel Automation - Save/Open fails in Scheduled Task

后端 未结 2 1526
长发绾君心
长发绾君心 2021-01-13 14:10

I created a simple powershell script that will create an excel instance and save a workbook:

$excel = New-Object -ComObject Excel.Application
$workbook = $ex         


        
2条回答
  •  天命终不由人
    2021-01-13 14:56

    I've been burned by this and didn't want to rewrite the code. I saw your post and several others which made me about to give up. However, my persistence paid off. I was trying to have Jenkins run a script to inventory our production environment and output to Excel. I didnt want a text doc because I was highlighting software versions that didnt match in RED, so needed Excel.

    Here is the answer that worked for me:

    You have to create a folder (or two on a 64bit-windows):

    (32Bit, always)

    C:\Windows\System32\config\systemprofile\Desktop

    (64Bit)

    C:\Windows\SysWOW64\config\systemprofile\Desktop

    Link that someone provided as the source:

    http://www.patton-tech.com/2012/05/printing-from-scheduled-task-as.html

    My source was:

    http://social.technet.microsoft.com/Forums/en/winserverpowershell/thread/aede572b-4c1f-4729-bc9d-899fed5fad02

提交回复
热议问题