This project has moved. For the latest updates, please go here.

Script runs fine on laptop but not server

May 4, 2016 at 7:37 PM
Edited May 4, 2016 at 7:45 PM
I have a pretty simple script right now:

-=-=-=-=- -=-=-=-=- -=-=-=-=- -=-=-=-=- -=-=-=-=-
$DLLPath = "E:\Scripts\Assembly\EPPlus.dll"
[Reflection.Assembly]::LoadFile($DLLPath) | Out-Null

$TodaysDate = Get-Date -Format D
$ExcelTemplateFileName = "E:\Scripts\Templates\Report-Margin.xlsx"

$ExcelApplication = New-Object OfficeOpenXml.ExcelPackage -ArgumentList $ExcelTemplateFileName
$Workbook = $ExcelApplication.Workbook
$ActiveWorksheet = $Workbook.Worksheets.Item("Sheet1")
$ActiveWorksheet.Cells[1, 5].Value = $TodaysDate
-=-=-=-=- -=-=-=-=- -=-=-=-=- -=-=-=-=- -=-=-=-=-

Which when executed from my laptop it works fine but the moment I run the exact same file from the server it reports:
Property 'Value' cannot be found on this object; make sure it exists and is settable.

What should I be checking on the server to make sure everything is there and working fine? I have already checked to make sure .NET 3.5 is there and EPPlus.DLL is in the correct location.
May 20, 2016 at 3:37 PM
I made two changes to the script. The first which I think was the actual reason why it started to work was that in Windows I clicked on the File Properties and Unblocked the DLL from restricted list. I'm not sure why this let it work in a manual state but not an automatic one but none the less it was one of the major steps I did.

The other major change I did was change the reference from Cells[1, 5].Value to Cells["E1"].Value.

Between the two I now have a fully functional report!