Community forum

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


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:
Sponsor
Forum information
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!
S.Servicedesk
2021-05-19T11:17:38Z
Originally Posted by: Support 


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



Hi,
When you execute the commands using a powershell file (.ps1) there error is the same.
Support
2021-05-19T15:07:29Z
I am not sure you answered my question. What if you connect locally on the server (from the powershell script).
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
bweston
2021-05-24T15:50:23Z
If I remember correctly, somewhere along the line it became necessary in my experience for CommClient.dll, CommClientCore.dll, and CommServer.dll to be in the Powershell subfolder of the Visualcron installation directory. I subsequently discovered that using a reparse point (hardlink, I think?) worked and persisted across Visualcron upgrades, as a result of which I haven't thought about it for a long time. Not sure whether it might pertain to your issue.

I also add-type the DLLs in the opposite order and use active directory for most of my connections, just to cover another couple of possibly irrelevant differences.
Support
2021-05-31T09:25:47Z
You should delete these files. Only use VisualCronAPI.dll and VisualCron.dll. The latest version of Comm.. is embedded so you might have a conflict if you keep these files.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
bweston
2021-06-02T14:13:36Z
Well, that's disconcerting to hear, since with the symbolic links removed I still get errors. If I get time for it later I will post another thread rather than hijacking this one, but for now I will need to put them back. It is worth noting that it is not the same error originally reported here.

S.Servicedesk, you said you cleared the error using your second code example but still weren't getting a connection. Are you still getting an error message or just no output? How are you determining that no connection is established? Are you checking the client connections from the GUI or perhaps the Visualcron logs? I noticed that your sample code doesn't assign the result of the call to $client.Connect to a variable in order to call any of the methods that send commands to the server, nor does it explicitly disconnect the client; I'm just taking some shots in the dark though.
S.Servicedesk
2021-08-13T11:39:26Z
Hi all,
Due to circumstances I was not able to look further into this.
Today I have checked again, this time using v9.8.5 on a Windows Server 2019 machine.
image.png

I created a Powershell task and added the below code

write-output "load DDL"
Add-Type -Path "E:\Apps\VisualCron\VisualCronAPI.dll"
Add-Type -Path "E:\Apps\VisualCron\VisualCron.dll"

write-output "setup CONN"
$Client     = New-Object -TypeName VisualCronAPI.Client
$conn = New-Object VisualCronAPI.Connection
$conn.Address = "{COMPUTER(Name)}"
$conn.username = "Test_User"
$conn.password = "Test_UserTest_User01"

write-output "Connect"
$connection = $client.Connect($conn,$true,$true)

write-output "Show the connection details"
$connection


This is the output of the task:
Please note the parameter "Status" is is set to disconnected. So it has made a connection and then the connection was dropped again. So any subsequent action will be against a closed connection.

load DDL
setup CONN
Connect
Show the connection details

License                      : VisualCronAPI.License
ClientConnections            : VisualCronAPI.ClientConnections
Jobs                         : VisualCronAPI.Jobs
Events                       : VisualCronAPI.Events
Certificates                 : VisualCronAPI.Certificates
SSHKeys                      : VisualCronAPI.SSHKeys
PGPKeyRings                  : VisualCronAPI.PGPKeyRings
Conditions                   : VisualCronAPI.Conditions
Connections                  : VisualCronAPI.Connections
Credentials                  : VisualCronAPI.Credentials
Notifications                : VisualCronAPI.Notifications
TaskRepository               : VisualCronAPI.TaskRepository
ExitCodes                    : VisualCronAPI.ExitCodes
Permissions                  : VisualCronAPI.Permissions
Processes                    : VisualCronAPI.Processes
Performance                  : VisualCronAPI.Performance
TimeExceptions               : VisualCronAPI.TimeExceptions
NetworkDrives                : VisualCronAPI.NetworkDrives
Variables                    : VisualCronAPI.Variables
Email                        : VisualCronAPI.EmailSettings
Explorer                     : VisualCronAPI.Explorer
Proxy                        : 
Log                          : VisualCronAPI.Log
Computer                     : VisualCronAPI.Computer
Flow                         : VisualCronAPI.Flow
Connection                   : VisualCronAPI.Connection
ServerId                     : 
MFT                          : VisualCronAPI.MFT
SyncSettings                 : VisualCronAPI.Sync
ClusterApi                   : VisualCronAPI.ClusterApi
CloudApi                     : VisualCronAPI.CloudApi
CloudServers                 : {}
TaskManager                  : VisualCronAPI.TaskManager
Client                       : VisualCronAPI.Client
Active                       : True
On                           : False
Port                         : 0
Authenticated                : False
InSync                       : False
🅱Status                       : Disconnected🅱
ServerTimeDiff               : 0
ServerTime                   : 8/13/2021 1:41:59 PM
TimeZoneName                 : 
UTCTimeOffset                : 00:00:00
Protocol                     : 9.0.0
Version                      : 
BuildDate                    : 12:00:00 AM
LimitOutput                  : True
LimitOutputSize              : 20480
MaxOutputSize                : 2147483647
Connected                    : True
LanguageId                   : 11
AllowLocalConnectionsOnly    : False
UserServerId                 : 2d8fb89d-b943-48f8-83b9-e9203a8096be
IP                           : 
SendErrorReportsToVisualCron : True
CodePage                     : 0
ServiceInfo                  : VisualCron.VisualCronServiceInfoClass
Settings                     : VisualCron.ServerSettingsClass
InvokeControl                : 
ConnectionTime               : 7.971
SyncTime                     : 0
ConnectionProgress           : 0
Scroll to Top