Setup connection to VC API using powershell - VisualCron - Forum

Community forum

S.Servicedesk
2021-04-22T09:59:44Z
I am working with the powershell sample provided in the visualcron installation directory.
Why i run that sample (with some minor) updates i get the below error:
S.Servicedesk
2021-04-22T10:01:47Z
Ok, something went wrong during the post of this topic.
The error i was referring to in my post was:

Exception calling "Connect" with "2" argument(s): "Object reference not set to an instance of an object."
At line:34 char:6
+         $Global:Server = $Client.Connect($conn, $true);
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : NullReferenceException

S.Servicedesk
2021-04-23T09:02:52Z
hi,

I managed to clear the error using the below code, however, the connection is still not being made with the VC server.
It seems that the script is executed but there is no connection being allowed by the VC server, it seems the server is not allowed to connect back to itself somehow.
Please note that i am running this code from VC itself, using the powershell execute task.


$Client     = New-Object -TypeName VisualCronAPI.Client

$conn = New-Object VisualCronAPI.Connection
$conn.Address = "{COMPUTER(Name)}"
$conn.username = "Test_User"
$conn.password = "************"
$client.Connect($conn,$true,$true)



Support
2021-04-23T13:21:34Z
Originally Posted by: S.Servicedesk 

hi,

I managed to clear the error using the below code, however, the connection is still not being made with the VC server.
It seems that the script is executed but there is no connection being allowed by the VC server, it seems the server is not allowed to connect back to itself somehow.
Please note that i am running this code from VC itself, using the powershell execute task.


$Client     = New-Object -TypeName VisualCronAPI.Client

$conn = New-Object VisualCronAPI.Connection
$conn.Address = "{COMPUTER(Name)}"
$conn.username = "Test_User"
$conn.password = "************"
$client.Connect($conn,$true,$true)





Does it behave the same way if you use the Execute task instead of the powershell task? In command, write the path to the powershell.exe, in argument, write the path to the powershell script file

Michael
Support
http://www.visualcron.com 

Please like  VisualCron on facebook!
S.Servicedesk
2021-04-23T14:12:35Z
Hi Michael,

I had to make an update the script in order to run it as an ps1 file. The output of the script is the same. There is no connection made to the VC server.

Add-Type -Path "E:\Apps\VisualCron\VisualCronAPI.dll"
Add-Type -Path "E:\Apps\VisualCron\VisualCron.dll"

$Client     = New-Object -TypeName VisualCronAPI.Client

$conn = New-Object VisualCronAPI.Connection
$conn.Address = $env:COMPUTERNAME
$conn.username = "Test_User"
$conn.password = "**************"
$client.Connect($conn,$true,$true)
Support
2021-04-29T15:39:25Z
Can you confirm if you try to connect locally on the Server or to another Server in the network?
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Scroll to Top