Monday, January 3, 2011

PowerShell, Windows Server 2008 & Excel 2010 64 Bit Scheduled Task Error

Are you trying to use PowerShell to generate a spreadsheet via a Scheduled Task using a 64 bit version of Excel 2010 on Windows Server 2008 64 bit and get the following error?

'Exception calling "SaveAs" with "1" argument(s): "SaveAs method of Workbook class failed"'

Yet, you do not get this error when running the script from the PowerShell command line? Frustrating isn't it? Quit banging your head against your desk and make sure this path is valid via PowerShell.
Test-Path -path $env:windir\System32\config\systemprofile\Desktop
If the return from this command is "False", run the following to create the directory.
New-Item -path $env:windir\System32\config\systemprofile\Desktop -type Directory

No comments:

Post a Comment