Exception in Task: Exception setting "ForegroundColor" - VisualCron - Forum

Community forum

Zeljko
2014-01-02T15:05:03Z
I'm calling from Visual Cron (7.0.8) using PowerShell option an PowerShell
script.

Script is correctly running from PowerShell IE on same machine and using same
credentials as Visual Cron does.

At time when I set-up Task in VC script had line like:
write-host -foregroundcolor green

Running the task I got error like:
Exception in Task: Exception setting "ForegroundColor": "Cannot convert null to type "System.ConsoleColor" due to enumeration values that are not valid. Specify one of the following enumeration values and try again. The possible enumeration values are "Black, DarkBlue, DarkGreen, DarkCyan, DarkRed, DarkMagenta, DarkYellow, Gray, DarkGray, Blue, Green, Cyan, Red, Magenta, Yellow, White".". Cannot convert null to type "System.ConsoleColor" due to enumeration values that are not valid. Specify one of the following enumeration values and try again. The possible enumeration values are "Black, DarkBlue, DarkGreen, DarkCyan, DarkRed, DarkMagenta, DarkYellow, Gray, DarkGray, Blue, Green, Cyan, Red, Magenta, Yellow, White".

I changed previous line into:
write-host -foregroundcolor [System.ConsoleColor]::Green

Still get SAME exception.

I deleted job/task and commented out that line , recreated job/task and same
error( Exception in Task: Exception setting "ForegroundColor": "Cannot convert null to type "System.ConsoleColor" due to enumeration values that are not valid. Specify one of the following enumeration values and try again. The possible enumeration values are "Black, DarkBlue,....)

During debugging session I found one another issue : line write-host "Test line"
also kills task in VC 7.0.8 when using PowerShell execute method.

Is there any document that list PowerShell bad list of statements to be used?
Support
2014-01-03T07:37:02Z
Thanks for the feedback. We do not have such a list but the host we use does not have any console so any interaction with that might fail.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Zeljko
2014-01-08T17:35:13Z
Hello Henrik,

I'm using VC 7.0.9 and I'm able
to call PowerShell script that calls another PowerShell script ( I tested this up to 3 levels deep).

I have a script RunTask that from PowerShell successfully runs Job with 5 Tasks (using VC APIs
referencing yours dlls: VisualCron.dll and VisualCronAPI.dll).
I can call this (RunTask) script by another PowerShell script and everything runs properly.

However,
when I setup VC task to call this RunTask script (either by command Execute or PowerShell option)
I get error message (edited real path for privacy concerns):

Exception calling "LoadFrom" with "1" argument(s): "Could not load file or
assembly 'file://\\myServer\Test\Include\VisualCronAPI.dll' or one of its dependencies. Operation is not supported.
(Exception from HRESULT: 0x80131515)"
At \\myServer\Test\RunVisualCronTasks.
ps1:26 char:1
+ $VCAPI =
[Reflection.Assembly]::LoadFrom("\\ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : FileLoadException

New-Object : Cannot find type [VisualCronAPI.Client]: make sure the assembly
containing this type is loaded.
At \\myServer\Test\RunVisualCronTasks.
ps1:30 char:19
+ $Global:Client = New-Object -TypeName VisualCronAPI.Client
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidType: (:) [New-Object], PSArgumentExcepti
on
+ FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewOb
jectCommand

New-Object : Cannot find type [VisualCronAPI.Server]: make sure the assembly
containing this t
Support
2014-01-08T17:39:12Z
Seems to be simplty that the file(s) (references) cannot be found. What if you place all files in the same folder?
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Zeljko
2014-01-08T17:52:40Z
It seems to be same case.
Zeljko
2014-01-09T18:17:05Z
This issue was related to .NET permissions. We added to configuration
file of PowerShell:
<runtime>
<loadfromremotesources enabled="true"/>
</runtime>
Support
2014-01-10T11:14:32Z
Thanks for the feedback!
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Samer
2017-07-10T06:13:40Z
Originally Posted by: Zeljko 

This issue was related to .NET permissions. We added to configuration
file of PowerShell:
<runtime>
<loadfromremotesources enabled="true"/>
</runtime>



I have exactly the same error, please check my last thread.

Your solution there didn't work tho, in which config file should I put this?
Support
2017-07-11T19:36:42Z
Originally Posted by: Samer 

Originally Posted by: Zeljko 

This issue was related to .NET permissions. We added to configuration
file of PowerShell:
<runtime>
<loadfromremotesources enabled="true"/>
</runtime>



I have exactly the same error, please check my last thread.

Your solution there didn't work tho, in which config file should I put this?




TaskPowerShell.exe.config

and
TaskPowerShellx86.exe.config
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Scroll to Top