Please note that VisualCron support is not actively monitoring this community forum. Please use our contact page for contacting the VisualCron support directly.


Samer
  •  Samer
  • Free support Topic Starter
2017-07-09T19:41:44Z
So this is my Powershell script; i hid the private info:


Quote:

cls
$username = "xxxxx";
$password = "yyyy";
$loginUrl = "https://uat.login.yyyyy.com/auth/XUI/#login/&goto=https%3A%2F%2Fuat.yyyyy.com%3A443%2Fscf%2F";
$ie = New-Object -com internetexplorer.application;
$ie.visible = $true;
$ie.navigate($loginUrl);
while ($ie.Busy -eq $true) { Start-Sleep -Seconds 10; }
Start-Sleep -s 5
($ie.Document.IHTMLDocument3_getElementById("idToken1") |select -first 1).value = $username;
($ie.Document.IHTMLDocument3_getElementById("idToken2") |select -first 1).value = $password;
($ie.Document.IHTMLDocument3_getElementById("loginButton_0") |select -first 1).click();
while ($ie.Busy -eq $true) { Start-Sleep -Seconds 15; }

Start-Sleep -s 15

if($ie.Document.IHTMLDocument3_getElementById("Submit") |select -first 1){
$Submit = $ie.Document.IHTMLDocument3_getElementById("Submit") |select -first 1;
$Submit.click()
}

Start-Sleep -s 15
$loginUrl2 = "https://uat.xxxxxxx.com/scf/community/runPoSearch.htm?summaryInfo=0&statusCode=30&obligorId=3FD5F01B0E85E6882CD044122D790489D1714F71919C0280&bbbbbb=&supplierId=&fiId=&documentNumber=&buyerUniqueDocId=&dateType=Maturity+Date&startDate=2017-05-26&endDate=2019-12-31&dateOption=today&dateRangeType=between&startDateView=May+26,+2017&endDateView=Dec+31,+2019&fromAmount=&toAmount=&amountRadio=exact&exactAmount=&specialDocumentType=&specialDocumentNumber=&currencyCode=";
$ie.navigate($loginUrl2);
Start-Sleep -s 15
$csv= $ie.Document.getElementsByTagName('span') | where-object {$_.className -eq 'export csv'}
$csv.click()
Start-Sleep -s 5
$ie.quit()




It works and it runs with no problem in Powershell terminal.


However, in VC, I get this error

Quote:

ExecuteProcess("C:\Program Files (x86)\VisualCron\\PowerShell\TaskPowerShellx86.exe" 3119497)->System.Management.Automation.SetValueInvocationException: 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"." ---> System.Management.Automation.PSInvalidCastException: 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".
at System.Management.Automation.LanguagePrimitives.ThrowInvalidCastException(Object valueToConvert, Type resultType)
at System.Management.Automation.LanguagePrimitives.ConvertNoConversion(Object valueToConvert, Type resultType, Boolean recurse, PSObject originalValueToConvert, IFormatProvider formatProvider, TypeTable backupTable)
at CallSite.Target(Closure , CallSite , Object , Object )
--- End of inner exception stack trace ---
at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
at TaskPowerShell.PowerShellTaskClass.Run(ProcessPowerShellTaskInfoClass ti, StringBuilder& sbStandardOut, StringBuilder& sbStandardError, Boolean& bolResult)



It's driving me to the wall, I heard it's related to loadfromremotesources (maybe it's consider VC as remote), I added this to the powershell config file, but still not working.
<runtime>
<loadfromremotesources enabled="true"/>
</runtime>

any help how to make it run in VC?
Sponsor
Forum information
Samer
  •  Samer
  • Free support Topic Starter
2017-07-10T06:20:49Z
Take note VC team: It was the CLS in the script.

CLS causes this error in powershell's VC.
Support
2017-07-11T19:38:49Z
Originally Posted by: Samer 

Take note VC team: It was the CLS in the script.

CLS causes this error in powershell's VC.



Thanks, yes, CLS is not available in the PowerShell host as there is no command window.

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