-
Notifications
You must be signed in to change notification settings - Fork 586
/
meshctrl.js
3178 lines (3084 loc) · 198 KB
/
meshctrl.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env node
/**
* @description MeshCentral command line tool
* @author Ylian Saint-Hilaire
* @copyright Intel Corporation 2018-2022
* @license Apache-2.0
* @version v0.0.1
*/
// Make sure we have the dependency modules
try { require('minimist'); } catch (ex) { console.log('Missing module "minimist", type "npm install minimist" to install it.'); return; }
try { require('ws'); } catch (ex) { console.log('Missing module "ws", type "npm install ws" to install it.'); return; }
var settings = {};
const crypto = require('crypto');
const args = require('minimist')(process.argv.slice(2));
const path = require('path');
const possibleCommands = ['edituser', 'listusers', 'listusersessions', 'listdevicegroups', 'listdevices', 'listusersofdevicegroup', 'listevents', 'logintokens', 'serverinfo', 'userinfo', 'adduser', 'removeuser', 'adddevicegroup', 'removedevicegroup', 'editdevicegroup', 'broadcast', 'showevents', 'addusertodevicegroup', 'removeuserfromdevicegroup', 'addusertodevice', 'removeuserfromdevice', 'sendinviteemail', 'generateinvitelink', 'config', 'movetodevicegroup', 'deviceinfo', 'removedevice', 'editdevice', 'addlocaldevice', 'addamtdevice', 'addusergroup', 'listusergroups', 'removeusergroup', 'runcommand', 'shell', 'upload', 'download', 'deviceopenurl', 'devicemessage', 'devicetoast', 'addtousergroup', 'removefromusergroup', 'removeallusersfromusergroup', 'devicesharing', 'devicepower', 'indexagenterrorlog', 'agentdownload', 'report', 'grouptoast', 'groupmessage', 'webrelay'];
if (args.proxy != null) { try { require('https-proxy-agent'); } catch (ex) { console.log('Missing module "https-proxy-agent", type "npm install https-proxy-agent" to install it.'); return; } }
if (args['_'].length == 0) {
console.log("MeshCtrl performs command line actions on a MeshCentral server.");
console.log("Information at: https://meshcentral.com");
console.log("No action specified, use MeshCtrl like this:\r\n\r\n meshctrl [action] [arguments]\r\n");
console.log("Supported actions:");
console.log(" Help [action] - Get help on an action.");
console.log(" ServerInfo - Show server information.");
console.log(" UserInfo - Show user information.");
console.log(" ListUsers - List user accounts.");
console.log(" ListUserSessions - List online users.");
console.log(" ListUserGroups - List user groups.");
console.log(" ListDevices - List devices.");
console.log(" ListDeviceGroups - List device groups.");
console.log(" ListUsersOfDeviceGroup - List the users in a device group.");
console.log(" ListEvents - List server events.");
console.log(" LoginTokens - List, create and remove login tokens.");
console.log(" DeviceInfo - Show information about a device.");
console.log(" AddLocalDevice - Add a local device.");
console.log(" AddAmtDevice - Add a AMT device.");
console.log(" EditDevice - Make changes to a device.");
console.log(" RemoveDevice - Delete a device.");
console.log(" Config - Perform operation on config.json file.");
console.log(" AddUser - Create a new user account.");
console.log(" EditUser - Change a user account.");
console.log(" RemoveUser - Delete a user account.");
console.log(" AddUserGroup - Create a new user group.");
console.log(" RemoveUserGroup - Delete a user group.");
console.log(" AddToUserGroup - Add a user, device or device group to a user group.");
console.log(" RemoveFromUserGroup - Remove a user, device or device group from a user group.");
console.log(" RemoveAllUsersFromUserGroup - Remove all users from a user group.");
console.log(" AddDeviceGroup - Create a new device group.");
console.log(" RemoveDeviceGroup - Delete a device group.");
console.log(" EditDeviceGroup - Change a device group values.");
console.log(" MoveToDeviceGroup - Move a device to a different device group.");
console.log(" AddUserToDeviceGroup - Add a user to a device group.");
console.log(" RemoveUserFromDeviceGroup - Remove a user from a device group.");
console.log(" AddUserToDevice - Add a user to a device.");
console.log(" RemoveUserFromDevice - Remove a user from a device.");
console.log(" SendInviteEmail - Send an agent install invitation email.");
console.log(" GenerateInviteLink - Create an invitation link.");
console.log(" Broadcast - Display a message to all online users.");
console.log(" ShowEvents - Display real-time server events in JSON format.");
console.log(" RunCommand - Run a shell command on a remote device.");
console.log(" Shell - Access command shell of a remote device.");
console.log(" Upload - Upload a file to a remote device.");
console.log(" Download - Download a file from a remote device.");
console.log(" WebRelay - Creates a HTTP/HTTPS webrelay link for a remote device.");
console.log(" DeviceOpenUrl - Open a URL on a remote device.");
console.log(" DeviceMessage - Open a message box on a remote device.");
console.log(" DeviceToast - Display a toast notification on a remote device.");
console.log(" GroupMessage - Open a message box on remote devices in a specific device group.");
console.log(" GroupToast - Display a toast notification on remote devices in a specific device group.");
console.log(" DevicePower - Perform wake/sleep/reset/off operations on remote devices.");
console.log(" DeviceSharing - View, add and remove sharing links for a given device.");
console.log(" AgentDownload - Download an agent of a specific type for a device group.");
console.log(" Report - Create and show a CSV report.");
console.log("\r\nSupported login arguments:");
console.log(" --url [wss://server] - Server url, wss://localhost:443 is default.");
console.log(" - Use wss://localhost:443?key=xxx if login key is required.");
console.log(" --loginuser [username] - Login username, admin is default.");
console.log(" --loginpass [password] - Login password OR Leave blank to enter password at prompt");
console.log(" --token [number] - 2nd factor authentication token.");
console.log(" --loginkey [hex] - Server login key in hex.");
console.log(" --loginkeyfile [file] - File containing server login key in hex.");
console.log(" --logindomain [domainid] - Domain id, default is empty, only used with loginkey.");
console.log(" --proxy [http://proxy:123] - Specify an HTTP proxy.");
return;
} else {
settings.cmd = args['_'][0].toLowerCase();
if ((possibleCommands.indexOf(settings.cmd) == -1) && (settings.cmd != 'help')) { console.log("Invalid command. Possible commands are: " + possibleCommands.join(', ') + '.'); return; }
//console.log(settings.cmd);
var ok = false;
switch (settings.cmd) {
case 'config': { performConfigOperations(args); return; }
case 'indexagenterrorlog': { indexAgentErrorLog(); return; }
case 'serverinfo': { ok = true; break; }
case 'userinfo': { ok = true; break; }
case 'listusers': { ok = true; break; }
case 'listusersessions': { ok = true; break; }
case 'listusergroups': { ok = true; break; }
case 'listdevicegroups': { ok = true; break; }
case 'listdevices': { ok = true; break; }
case 'listevents': { ok = true; break; }
case 'logintokens': { ok = true; break; }
case 'listusersofdevicegroup':
case 'deviceinfo':
case 'removedevice':
case 'editdevice': {
if (args.id == null) { console.log(winRemoveSingleQuotes("Missing device id, use --id '[deviceid]'")); }
else { ok = true; }
break;
}
case 'addlocaldevice': {
if (args.id == null) { console.log(winRemoveSingleQuotes("Missing device id, use --id '[deviceid]'")); }
else if (args.devicename == null) { console.log(winRemoveSingleQuotes("Missing devicename, use --devicename [devicename]")); }
else if (args.hostname == null) { console.log(winRemoveSingleQuotes("Missing hostname, use --hostname [hostname]")); }
else { ok = true; }
break;
}
case 'addamtdevice': {
if (args.id == null) { console.log(winRemoveSingleQuotes("Missing device id, use --id '[deviceid]'")); }
else if (args.devicename == null) { console.log(winRemoveSingleQuotes("Missing devicename, use --devicename [devicename]")); }
else if (args.hostname == null) { console.log(winRemoveSingleQuotes("Missing hostname, use --hostname [hostname]")); }
else if (args.user == null) { console.log(winRemoveSingleQuotes("Missing user, use --user [user]")); }
else if (args.pass == null) { console.log(winRemoveSingleQuotes("Missing pass, use --pass [pass]")); }
else { ok = true; }
break;
}
case 'addusertodevicegroup': {
if ((args.id == null) && (args.group == null)) { console.log(winRemoveSingleQuotes("Device group identifier missing, use --id '[groupid]' or --group [groupname]")); }
else if (args.userid == null) { console.log("Add user to group missing useid, use --userid [userid]"); }
else { ok = true; }
break;
}
case 'removeuserfromdevicegroup': {
if ((args.id == null) && (args.group == null)) { console.log(winRemoveSingleQuotes("Device group identifier missing, use --id '[groupid]' or --group [groupname]")); }
else if (args.userid == null) { console.log("Remove user from group missing useid, use --userid [userid]"); }
else { ok = true; }
break;
}
case 'addusertodevice': {
if (args.userid == null) { console.log("Add user to device missing userid, use --userid [userid]"); }
else if (args.id == null) { console.log(winRemoveSingleQuotes("Add user to device missing device id, use --id '[deviceid]'")); }
else { ok = true; }
break;
}
case 'removeuserfromdevice': {
if (args.userid == null) { console.log("Remove user from device missing userid, use --userid [userid]"); }
else if (args.id == null) { console.log(winRemoveSingleQuotes("Remove user from device missing device id, use --id '[deviceid]'")); }
else { ok = true; }
break;
}
case 'adddevicegroup': {
if (args.name == null) { console.log("Message group name, use --name [name]"); }
else { ok = true; }
break;
}
case 'editdevicegroup':
case 'removedevicegroup': {
if ((args.id == null) && (args.group == null)) { console.log(winRemoveSingleQuotes("Device group identifier missing, use --id '[groupid]' or --group [groupname]")); }
else { ok = true; }
break;
}
case 'movetodevicegroup': {
if ((args.id == null) && (args.group == null)) { console.log(winRemoveSingleQuotes("Device group identifier missing, use --id '[groupid]' or --group [groupname]")); }
else if (args.devid == null) { console.log(winRemoveSingleQuotes("Device identifier missing, use --devid '[deviceid]'")); }
else { ok = true; }
break;
}
case 'broadcast': {
if (args.msg == null) { console.log("Message missing, use --msg [message]"); }
else { ok = true; }
break;
}
case 'showevents': {
ok = true;
break;
}
case 'adduser': {
if (args.user == null) { console.log("New account name missing, use --user [name]"); }
else if ((args.pass == null) && (args.randompass == null)) { console.log("New account password missing, use --pass [password] or --randompass"); }
else { ok = true; }
break;
}
case 'edituser': {
if (args.userid == null) { console.log("Edit account user missing, use --userid [id]"); }
else { ok = true; }
break;
}
case 'removeuser': {
if (args.userid == null) { console.log("Remove account userid missing, use --userid [id]"); }
else { ok = true; }
break;
}
case 'addusergroup': {
if (args.name == null) { console.log("New user group name missing, use --name [name]"); }
else { ok = true; }
break;
}
case 'removeusergroup': {
if (args.groupid == null) { console.log(winRemoveSingleQuotes("Remove user group id missing, use --groupid '[id]'")); }
else { ok = true; }
break;
}
case 'addtousergroup': {
if (args.groupid == null) { console.log(winRemoveSingleQuotes("Group id missing, use --groupid '[id]'")); }
if (args.id == null) { console.log(winRemoveSingleQuotes("Missing identifier to add, use --id [id]")); }
else { ok = true; }
break;
}
case 'removefromusergroup': {
if (args.groupid == null) { console.log(winRemoveSingleQuotes("Group id missing, use --groupid '[id]'")); }
if (args.id == null) { console.log(winRemoveSingleQuotes("Missing identifier to remove, use --id [id]")); }
else { ok = true; }
break;
}
case 'removeallusersfromusergroup': {
if (args.groupid == null) { console.log(winRemoveSingleQuotes("Group id missing, use --groupid '[id]'")); }
else { ok = true; }
break;
}
case 'sendinviteemail': {
if ((args.id == null) && (args.group == null)) { console.log("Device group identifier missing, use --id '[groupid]' or --group [groupname]"); }
else if (args.email == null) { console.log("Device email is missing, use --email [email]"); }
else { ok = true; }
break;
}
case 'generateinvitelink': {
if ((args.id == null) && (args.group == null)) { console.log("Device group identifier missing, use --id '[groupid]' or --group [groupname]"); }
else if (args.hours == null) { console.log("Invitation validity period missing, use --hours [hours]"); }
else { ok = true; }
break;
}
case 'runcommand': {
if (args.id == null) { console.log(winRemoveSingleQuotes("Missing device id, use --id '[deviceid]'")); }
else if (args.run == null) { console.log("Missing run, use --run \"command\""); }
else { ok = true; }
break;
}
case 'shell': {
if (args.id == null) { console.log(winRemoveSingleQuotes("Missing device id, use --id '[deviceid]'")); }
else { ok = true; }
break;
}
case 'devicepower': {
if (args.id == null) { console.log(winRemoveSingleQuotes("Missing device id, use --id '[deviceid]'")); }
else { ok = true; }
break;
}
case 'devicesharing': {
if (args.id == null) { console.log(winRemoveSingleQuotes("Missing device id, use --id '[deviceid]'")); }
else if ((args.daily != null) && (args.weekly != null)) { console.log(winRemoveSingleQuotes("Can't specify both --daily and --weekly at the same time.")); }
else { ok = true; }
break;
}
case 'agentdownload': {
if (args.type == null) { console.log(winRemoveSingleQuotes("Missing device type, use --type [agenttype]")); }
else if ((parseInt(args.type) == null) || isNaN(parseInt(args.type)) || (parseInt(args.type) < 1) || (parseInt(args.type) > 11000)) { console.log(winRemoveSingleQuotes("Invalid agent type, must be a number.")); }
else if (args.id == null) { console.log(winRemoveSingleQuotes("Missing device id, use --id '[meshid]'")); }
else if ((typeof args.id != 'string') || (args.id.length != 64)) { console.log(winRemoveSingleQuotes("Invalid meshid.")); }
else { ok = true; }
break;
}
case 'upload': {
if (args.id == null) { console.log(winRemoveSingleQuotes("Missing device id, use --id '[deviceid]'")); }
else if (args.file == null) { console.log("Local file missing, use --file [file] specify the file to upload"); }
else if (args.target == null) { console.log("Remote target path missing, use --target [path] to specify the remote location"); }
else if (require('fs').existsSync(args.file) == false) { console.log("Local file does not exists, check --file"); }
else { ok = true; }
break;
}
case 'download': {
if (args.id == null) { console.log(winRemoveSingleQuotes("Missing device id, use --id '[deviceid]'")); }
else if (args.file == null) { console.log("Remote file missing, use --file [file] specify the remote file to download"); }
else if (args.target == null) { console.log("Target path missing, use --target [path] to specify the local download location"); }
else { ok = true; }
break;
}
case 'webrelay': {
if (args.id == null) { console.log(winRemoveSingleQuotes("Missing device id, use --id '[deviceid]'")); }
else if (args.type == null) { console.log(winRemoveSingleQuotes("Missing protocol type, use --type [http,https]")); }
else { ok = true; }
break;
}
case 'deviceopenurl': {
if (args.id == null) { console.log(winRemoveSingleQuotes("Missing device id, use --id '[deviceid]'")); }
else if (args.openurl == null) { console.log("Remote URL, use --openurl [url] specify the link to open."); }
else { ok = true; }
break;
}
case 'devicemessage': {
if (args.id == null) { console.log(winRemoveSingleQuotes("Missing device id, use --id '[deviceid]'")); }
else if (args.msg == null) { console.log("Remote message, use --msg \"[message]\" specify a remote message."); }
else { ok = true; }
break;
}
case 'devicetoast': {
if (args.id == null) { console.log(winRemoveSingleQuotes("Missing device id, use --id '[deviceid]'")); }
else if (args.msg == null) { console.log("Remote message, use --msg \"[message]\" specify a remote message."); }
else { ok = true; }
break;
}
case 'groupmessage': {
if (args.id == null) { console.log(winRemoveSingleQuotes("Missing device group id, use --id '[devicegroupid]'")); }
else if (args.msg == null) { console.log("Remote message, use --msg \"[message]\" specify a remote message."); }
else { ok = true; }
break;
}
case 'grouptoast': {
if (args.id == null) { console.log(winRemoveSingleQuotes("Missing device group id, use --id '[devicegroupid]'")); }
else if (args.msg == null) { console.log("Remote message, use --msg \"[message]\" specify a remote message."); }
else { ok = true; }
break;
}
case 'report': {
if (args.type == null) { console.log(winRemoveSingleQuotes("Missing report type, use --type '[reporttype]'")); }
else { ok = true; }
break;
}
case 'help': {
if (args['_'].length < 2) {
console.log("Get help on an action. Type:\r\n\r\n help [action]\r\n\r\nPossible actions are: " + possibleCommands.join(', ') + '.');
} else {
switch (args['_'][1].toLowerCase()) {
case 'config': {
displayConfigHelp();
break;
}
case 'sendinviteemail': {
console.log("Send invitation email with instructions on how to install the mesh agent for a specific device group. Example usage:\r\n");
console.log(winRemoveSingleQuotes(" MeshCtrl SendInviteEmail --id 'groupid' --message \"msg\" --email [email protected]"));
console.log(winRemoveSingleQuotes(" MeshCtrl SendInviteEmail --group \"My Computers\" --name \"Jack\" --email [email protected]"));
console.log("\r\nRequired arguments:\r\n");
if (process.platform == 'win32') {
console.log(" --id [groupid] - Device group identifier (or --group).");
} else {
console.log(" --id '[groupid]' - Device group identifier (or --group).");
}
console.log(" --group [groupname] - Device group name (or --id).");
console.log(" --email [email] - Email address.");
console.log("\r\nOptional arguments:\r\n");
console.log(" --name (name) - Name of recipient to be included in the email.");
console.log(" --message (msg) - Message to be included in the email.");
break;
}
case 'generateinvitelink': {
console.log("Generate a agent invitation URL for a given group. Example usage:\r\n");
console.log(winRemoveSingleQuotes(" MeshCtrl GenerateInviteLink --id 'groupid' --hours 24"));
console.log(" MeshCtrl GenerateInviteLink --group \"My Computers\" --hours 0");
console.log("\r\nRequired arguments:\r\n");
if (process.platform == 'win32') {
console.log(" --id [groupid] - Device group identifier (or --group).");
} else {
console.log(" --id '[groupid]' - Device group identifier (or --group).");
}
console.log(" --group [groupname] - Device group name (or --id).");
console.log(" --hours [hours] - Validity period in hours or 0 for infinite.");
console.log("\r\nOptional arguments:\r\n");
console.log(" --flags [mode] - Mode flag for link type (0 = both, 1 = interactive only, 2 = background only)");
break;
}
case 'showevents': {
console.log("Show the server's event stream for this user account. Example usage:\r\n");
console.log(" MeshCtrl ShowEvents");
console.log(" MeshCtrl ShowEvents --filter nodeconnect");
console.log(" MeshCtrl ShowEvents --filter uicustomevent,changenode");
console.log("\r\nOptional arguments:\r\n");
console.log(" --filter [actions] - Show only specified actions.");
break;
}
case 'serverinfo': {
console.log("Get information on the MeshCentral server, Example usages:\r\n");
console.log(" MeshCtrl ServerInfo --loginuser myaccountname --loginpass mypassword");
console.log(" MeshCtrl ServerInfo --loginuser myaccountname --loginkeyfile key.txt");
console.log("\r\nOptional arguments:\r\n");
console.log(" --json - Show result as JSON.");
break;
}
case 'userinfo': {
console.log("Get account information for the login account, Example usages:\r\n");
console.log(" MeshCtrl UserInfo --loginuser myaccountname --loginpass mypassword");
console.log(" MeshCtrl UserInfo --loginuser myaccountname --loginkeyfile key.txt");
console.log("\r\nOptional arguments:\r\n");
console.log(" --json - Show result as JSON.");
break;
}
case 'listusers': {
console.log("List the account on the MeshCentral server, Example usages:\r\n");
console.log(" MeshCtrl ListUsers");
console.log(" MeshCtrl ListUsers --json");
console.log(" MeshCtrl ListUsers --nameexists \"bob\"");
console.log(" MeshCtrl ListUsers --filter 2fa");
console.log("\r\nOptional arguments:\r\n");
console.log(" --idexists [id] - Return 1 if id exists, 0 if not.");
console.log(" --nameexists [name] - Return id if name exists.");
console.log(" --filter [filter1,...] - Filter user names: 2FA, NO2FA.");
console.log(" --json - Show result as JSON.");
break;
}
case 'listusersessions': {
console.log("List active user sessions on the MeshCentral server, Example usages:\r\n");
console.log(" MeshCtrl ListUserSessions");
console.log(" MeshCtrl ListUserSessions --json");
break;
}
case 'listusergroups': {
console.log("List user groups on the MeshCentral server, Example usages:\r\n");
console.log(" MeshCtrl ListUserGroups");
console.log(" MeshCtrl ListUserGroups --json");
break;
}
case 'listdevicegroups': {
console.log("List the device groups for this account. Example usages:\r\n");
console.log(" MeshCtrl ListDeviceGroups ");
console.log(" MeshCtrl ListDeviceGroups --json");
console.log("\r\nOptional arguments:\r\n");
console.log(" --idexists [id] - Return 1 if id exists, 0 if not.");
console.log(" --nameexists [name] - Return id if name exists.");
console.log(" --emailexists [email] - Return id if email exists.");
console.log(" --hex - Display meshid in hex format.");
console.log(" --json - Show result as JSON.");
break;
}
case 'listdevices': {
console.log("List devices. Example usages:\r\n");
console.log(" MeshCtrl ListDevices");
console.log(winRemoveSingleQuotes(" MeshCtrl ListDevices -id '[groupid]' --json"));
console.log("\r\nOptional arguments:\r\n");
if (process.platform == 'win32') {
console.log(" --id [groupid] - Filter by group identifier (or --group).");
} else {
console.log(" --id '[groupid]' - Filter by group identifier (or --group).");
}
console.log(" --group [groupname] - Filter by group name (or --id).");
console.log(" --count - Only return the device count.");
console.log(" --json - Show result as JSON.");
console.log(" --csv - Show result as comma separated values.");
console.log(" --filter \"[filter]\" - Filter devices using a filter string.");
console.log(" \"x\" - Devices with \"x\" in the name.");
console.log(" \"user:x or u:x\" - Devices with \"x\" in the name of currently logged in user.");
console.log(" \"ip:x\" - Devices \"x\" IP address.");
console.log(" \"group:x or g:x\" - Devices with \"x\" in device group name.");
console.log(" \"tag:x or t:x\" - Devices with \"x\" in device tag.");
console.log(" \"atag:x or a:x\" - Devices with \"x\" in device agent tag.");
console.log(" \"os:x\" - Devices with \"x\" in the device OS description.");
console.log(" \"amt:x\" - Devices with Intel AMT provisioning state (0, 1, 2).");
console.log(" \"desc:x\" - Devices with \"x\" in device description.");
console.log(" \"wsc:ok\" - Devices with Windows Security Center ok.");
console.log(" \"wsc:noav\" - Devices with Windows Security Center with anti-virus problem.");
console.log(" \"wsc:noupdate\" - Devices with Windows Security Center with update problem.");
console.log(" \"wsc:nofirewall\" - Devices with Windows Security Center with firewall problem.");
console.log(" \"wsc:any\" - Devices with Windows Security Center with any problem.");
console.log(" \"a and b\" - Match both conditions with precedence over OR. For example: \"lab and g:home\".");
console.log(" \"a or b\" - Math one of the conditions, for example: \"lab or g:home\".");
console.log(" --filterid [id,id...] - Show only results for devices with included id.");
console.log(" --details - Show all device details.");
break;
}
case 'listusersofdevicegroup': {
console.log("List users that have permissions for a given device group. Example usage:\r\n");
console.log(" MeshCtrl ListUserOfDeviceGroup ");
console.log("\r\nRequired arguments:\r\n");
if (process.platform == 'win32') {
console.log(" --id [groupid] - Device group identifier.");
} else {
console.log(" --id '[groupid]' - Device group identifier.");
}
console.log("\r\nOptional arguments:\r\n");
console.log(" --json - Show result as JSON.");
break;
}
case 'listevents': {
console.log("List server events optionally filtered by user or device. Example usage:\r\n");
console.log(" MeshCtrl ListEvents ");
console.log("\r\nOptional arguments:\r\n");
console.log(" --userid [name] - User account identifier.");
console.log(" --id [deviceid] - The device identifier.");
console.log(" --limit [number] - Maximum number of events to list.");
console.log(" --raw - Output raw data in JSON format.");
console.log(" --json - Give results in JSON format.");
break;
}
case 'logintokens': {
console.log("List account login tokens and allow addition and removal. Example usage:\r\n");
console.log(" MeshCtrl LoginTokens ");
console.log("\r\nOptional arguments:\r\n");
console.log(" --remove [name] - Remove a login token.");
console.log(" --add [name] - Add a login token.");
console.log(" --expire [minutes] - When adding a token, minutes until expire.");
console.log(" --json - Show login tokens in JSON format.");
break;
}
case 'adduser': {
console.log("Add a new user account. Example usages:\r\n");
console.log(" MeshCtrl AddUser --user newaccountname --pass newpassword");
console.log(" MeshCtrl AddUser --user newaccountname --randompass --rights full");
console.log("\r\nRequired arguments:\r\n");
console.log(" --user [name] - New account name.");
console.log(" --pass [password] - New account password.");
console.log(" --randompass - Create account with a random password.");
console.log("\r\nOptional arguments:\r\n");
console.log(" --domain [domain] - Account domain, only for cross-domain admins.");
console.log(" --email [email] - New account email address.");
console.log(" --emailverified - New account email is verified.");
console.log(" --resetpass - Request password reset on next login.");
console.log(" --realname [name] - Set the real name for this account.");
console.log(" --phone [number] - Set the account phone number.");
console.log(" --rights [none|full|a,b,c] - Comma separated list of server permissions. Possible values:");
console.log(" manageusers,serverbackup,serverrestore,serverupdate,fileaccess,locked,nonewgroups,notools,usergroups,recordings,locksettings,allevents,nonewdevices");
break;
}
case 'edituser': {
console.log("Edit a user account, Example usages:\r\n");
console.log(" MeshCtrl EditUser --userid user --rights locked,locksettings");
console.log(" MeshCtrl EditUser --userid user --realname Jones");
console.log("\r\nRequired arguments:\r\n");
console.log(" --userid [name] - User account identifier.");
console.log("\r\nOptional arguments:\r\n");
console.log(" --domain [domain] - Account domain, only for cross-domain admins.");
console.log(" --email [email] - Account email address.");
console.log(" --emailverified - Account email is verified.");
console.log(" --resetpass - Request password reset on next login.");
console.log(" --realname [name] - Set the real name for this account.");
console.log(" --phone [number] - Set the account phone number.");
console.log(" --rights [none|full|a,b,c] - Comma separated list of server permissions. Possible values:");
console.log(" manageusers,serverbackup,serverrestore,serverupdate,fileaccess,locked,nonewgroups,notools,usergroups,recordings,locksettings,allevents,nonewdevices");
break;
}
case 'removeuser': {
console.log("Delete a user account, Example usages:\r\n");
console.log(" MeshCtrl RemoveUser --userid accountid");
console.log("\r\nRequired arguments:\r\n");
console.log(" --userid [id] - Account identifier.");
break;
}
case 'addusergroup': {
console.log("Create a new user group, Example usages:\r\n");
console.log(" MeshCtrl AddUserGroup --name \"Test Group\"");
console.log("\r\nRequired arguments:\r\n");
console.log(" --name [name] - Name of the user group.");
break;
}
case 'removeusergroup': {
console.log("Remove a user group, Example usages:\r\n");
console.log(winRemoveSingleQuotes(" MeshCtrl RemoveUserGroup --groupid 'ugrp//abcdf'"));
console.log("\r\nRequired arguments:\r\n");
if (process.platform == 'win32') {
console.log(" --groupid [groupid] - User group identifier.");
} else {
console.log(" --groupid '[groupid]' - User group identifier.");
}
break;
}
case 'addtousergroup': {
console.log("Add a user, device or device group to a user group, Example usages:\r\n");
console.log(winRemoveSingleQuotes(" MeshCtrl AddToUserGroup --id 'user//abcdef' --groupid 'ugrp//abcdf'"));
console.log(winRemoveSingleQuotes(" MeshCtrl AddToUserGroup --id 'node//abcdef' --groupid 'ugrp//abcdf' --rights [rights]"));
console.log(winRemoveSingleQuotes(" MeshCtrl AddToUserGroup --id 'mesh//abcdef' --groupid 'ugrp//abcdf' --rights [rights]"));
console.log("\r\nRequired arguments:\r\n");
if (process.platform == 'win32') {
console.log(" --id [id] - Identifier to add.");
console.log(" --groupid [groupid] - User group identifier.");
} else {
console.log(" --id '[id]' - Identifier to add.");
console.log(" --groupid '[groupid]' - User group identifier.");
}
console.log("\r\nOptional arguments:\r\n");
console.log(" --rights [number] - Rights granted for adding device or device group.");
console.log(" - 4294967295 for full admin or the sum of the following numbers.");
console.log(" 1 = Edit Device Group 2 = Manage Users ");
console.log(" 4 = Manage Computers 8 = Remote Control ");
console.log(" 16 = Agent Console 32 = Server Files ");
console.log(" 64 = Wake Device 128 = Set Notes ");
console.log(" 256 = Remote View Only 512 = No Terminal ");
console.log(" 1024 = No Files 2048 = No Intel AMT ");
console.log(" 4096 = Desktop Limited Input 8192 = Limit Events ");
console.log(" 16384 = Chat / Notify 32768 = Uninstall Agent ");
console.log(" 65536 = No Remote Desktop 131072 = Remote Commands ");
console.log(" 262144 = Reset / Power off ");
break;
}
case 'removefromusergroup': {
console.log("Remove a user, device or device group from a user group, Example usages:\r\n");
console.log(winRemoveSingleQuotes(" MeshCtrl RemoveUserFromUserGroup --userid 'user//abcdef' --groupid 'ugrp//abcdf'"));
console.log(winRemoveSingleQuotes(" MeshCtrl RemoveUserFromUserGroup --userid 'node//abcdef' --groupid 'ugrp//abcdf'"));
console.log(winRemoveSingleQuotes(" MeshCtrl RemoveUserFromUserGroup --userid 'mesh//abcdef' --groupid 'ugrp//abcdf'"));
console.log("\r\nRequired arguments:\r\n");
if (process.platform == 'win32') {
console.log(" --id [userid] - Identifier to remove.");
console.log(" --groupid [groupid] - User group identifier.");
} else {
console.log(" --id '[userid]' - Identifier to remove.");
console.log(" --groupid '[groupid]' - User group identifier.");
}
break;
}
case 'removeallusersfromusergroup': {
console.log("Remove all users from a user group, Example usages:\r\n");
console.log(winRemoveSingleQuotes(" MeshCtrl RemoveAllUsersFromUserGroup --groupid 'ugrp//abcdf'"));
console.log("\r\nRequired arguments:\r\n");
if (process.platform == 'win32') {
console.log(" --groupid [groupid] - User group identifier.");
} else {
console.log(" --groupid '[groupid]' - User group identifier.");
}
break;
}
case 'adddevicegroup': {
console.log("Add a device group, Example usages:\r\n");
console.log(" MeshCtrl AddDeviceGroup --name newgroupname");
console.log(" MeshCtrl AddDeviceGroup --name newgroupname --desc description --amtonly");
console.log(" MeshCtrl AddDeviceGroup --name newgroupname --features 1 --consent 7");
console.log("\r\nRequired arguments:\r\n");
console.log(" --name [name] - Name of the new group.");
console.log("\r\nOptional arguments:\r\n");
console.log(" --desc [description] - New group description.");
console.log(" --amtonly - New group is agent-less, Intel AMT only.");
console.log(" --agentless - New group is agent-less only.");
console.log(" --features [number] - Set device group features, sum of numbers below.");
console.log(" 1 = Auto-Remove 2 = Hostname Sync");
console.log(" 4 = Record Sessions");
console.log(" --consent [number] - Set device group user consent, sum of numbers below.");
console.log(" 1 = Desktop notify user 2 = Terminal notify user ");
console.log(" 4 = Files notify user 8 = Desktop prompt user ");
console.log(" 16 = Terminal prompt user 32 = Files prompt user ");
console.log(" 64 = Desktop Toolbar ");
break;
}
case 'removedevicegroup': {
console.log("Remove a device group, Example usages:\r\n");
console.log(winRemoveSingleQuotes(" MeshCtrl RemoveDeviceGroup --id 'groupid'"));
console.log("\r\nRequired arguments:\r\n");
if (process.platform == 'win32') {
console.log(" --id [groupid] - Device group identifier (or --group).");
} else {
console.log(" --id '[groupid]' - Device group identifier (or --group).");
}
console.log(" --group [groupname] - Device group name (or --id).");
break;
}
case 'editdevicegroup': {
console.log("Edit a device group, Example usages:\r\n");
console.log(winRemoveSingleQuotes(" MeshCtrl EditDeviceGroup --id 'groupid' --name \"New Name\""));
console.log(winRemoveSingleQuotes(" MeshCtrl EditDeviceGroup --id 'groupid' --desc \"Description\" --consent 63"));
console.log(winRemoveSingleQuotes(" MeshCtrl EditDeviceGroup --id 'groupid' --invitecodes \"code1,code2\" --backgroundonly"));
console.log("\r\nRequired arguments:\r\n");
if (process.platform == 'win32') {
console.log(" --id [groupid] - Device group identifier (or --group).");
} else {
console.log(" --id '[groupid]' - Device group identifier (or --group).");
}
console.log(" --group [groupname] - Device group name (or --id).");
console.log("\r\nOptional arguments:\r\n");
console.log(" --name [name] - Set new device group name.");
console.log(" --desc [description] - Set new device group description, blank to clear.");
console.log(" --flags [number] - Set device group flags, sum of the values below, 0 for none.");
console.log(" 1 = Auto remove device on disconnect.");
console.log(" 2 = Sync hostname.");
console.log(" --consent [number] - Set device group consent options, sum of the values below, 0 for none.");
console.log(" 1 = Desktop notify user.");
console.log(" 2 = Terminal notify user.");
console.log(" 4 = Files notify user.");
console.log(" 8 = Desktop prompt for user consent.");
console.log(" 16 = Terminal prompt for user consent.");
console.log(" 32 = Files prompt for user consent.");
console.log(" 64 = Desktop show connection toolbar.");
console.log(" --invitecodes [aa,bb] - Comma separated list of invite codes, blank to clear.");
console.log(" --backgroundonly - When used with invitecodes, set agent to only install in background.");
console.log(" --interactiveonly - When used with invitecodes, set agent to only run on demand.");
break;
}
case 'movetodevicegroup': {
console.log("Move a device to a new device group, Example usages:\r\n");
console.log(winRemoveSingleQuotes(" MeshCtrl MoveToDeviceGroup --devid 'deviceid' --id 'groupid'"));
console.log("\r\nRequired arguments:\r\n");
if (process.platform == 'win32') {
console.log(" --id [groupid] - Device group identifier (or --group).");
} else {
console.log(" --id '[groupid]' - Device group identifier (or --group).");
}
console.log(" --group [groupname] - Device group name (or --id).");
if (process.platform == 'win32') {
console.log(" --devid [deviceid] - Device identifier.");
} else {
console.log(" --devid '[deviceid]' - Device identifier.");
}
break;
}
case 'addusertodevicegroup': {
console.log("Add a user to a device group, Example usages:\r\n");
console.log(winRemoveSingleQuotes(" MeshCtrl AddUserToDeviceGroup --id 'groupid' --userid userid --fullrights"));
console.log(" MeshCtrl AddUserToDeviceGroup --group groupname --userid userid --editgroup --manageusers");
console.log("\r\nRequired arguments:\r\n");
if (process.platform == 'win32') {
console.log(" --id [groupid] - Device group identifier (or --group).");
} else {
console.log(" --id '[groupid]' - Device group identifier (or --group).");
}
console.log(" --group [groupname] - Device group name (or --id).");
console.log(" --userid [userid] - The user identifier.");
console.log("\r\nOptional arguments:\r\n");
console.log(" --fullrights - Allow full rights over this device group.");
console.log(" --editgroup - Allow the user to edit group information.");
console.log(" --manageusers - Allow the user to add/remove users.");
console.log(" --managedevices - Allow the user to edit device information.");
console.log(" --remotecontrol - Allow device remote control operations.");
console.log(" --agentconsole - Allow agent console operations.");
console.log(" --serverfiles - Allow access to group server files.");
console.log(" --wakedevices - Allow device wake operation.");
console.log(" --notes - Allow editing of device notes.");
console.log(" --desktopviewonly - Restrict user to view-only remote desktop.");
console.log(" --limiteddesktop - Limit remote desktop keys.");
console.log(" --noterminal - Hide the terminal tab from this user.");
console.log(" --nofiles - Hide the files tab from this user.");
console.log(" --noamt - Hide the Intel AMT tab from this user.");
console.log(" --limitedevents - User can only see his own events.");
console.log(" --chatnotify - Allow chat and notification options.");
console.log(" --uninstall - Allow remote uninstall of the agent.");
if (args.limiteddesktop) { meshrights |= 4096; }
if (args.limitedevents) { meshrights |= 8192; }
if (args.chatnotify) { meshrights |= 16384; }
if (args.uninstall) { meshrights |= 32768; }
break;
}
case 'removeuserfromdevicegroup': {
console.log("Remove a user from a device group, Example usages:\r\n");
console.log(winRemoveSingleQuotes(" MeshCtrl RemoveuserFromDeviceGroup --id 'groupid' --userid userid"));
console.log("\r\nRequired arguments:\r\n");
if (process.platform == 'win32') {
console.log(" --id [groupid] - Device group identifier (or --group).");
} else {
console.log(" --id '[groupid]' - Device group identifier (or --group).");
}
console.log(" --group [groupname] - Device group name (or --id).");
console.log(" --userid [userid] - The user identifier.");
break;
}
case 'addusertodevice': {
console.log("Add a user to a device, Example usages:\r\n");
console.log(winRemoveSingleQuotes(" MeshCtrl AddUserToDevice --id 'deviceid' --userid userid --fullrights"));
console.log(winRemoveSingleQuotes(" MeshCtrl AddUserToDevice --id 'deviceid' --userid userid --remotecontrol"));
console.log("\r\nRequired arguments:\r\n");
if (process.platform == 'win32') {
console.log(" --id [deviceid] - The device identifier.");
} else {
console.log(" --id '[deviceid]' - The device identifier.");
}
console.log(" --userid [userid] - The user identifier.");
console.log("\r\nOptional arguments:\r\n");
console.log(" --fullrights - Allow full rights over this device.");
console.log(" --remotecontrol - Allow device remote control operations.");
console.log(" --agentconsole - Allow agent console operations.");
console.log(" --serverfiles - Allow access to group server files.");
console.log(" --wakedevices - Allow device wake operation.");
console.log(" --notes - Allow editing of device notes.");
console.log(" --desktopviewonly - Restrict user to view-only remote desktop.");
console.log(" --limiteddesktop - Limit remote desktop keys.");
console.log(" --noterminal - Hide the terminal tab from this user.");
console.log(" --nofiles - Hide the files tab from this user.");
console.log(" --noamt - Hide the Intel AMT tab from this user.");
console.log(" --limitedevents - User can only see his own events.");
console.log(" --chatnotify - Allow chat and notification options.");
console.log(" --uninstall - Allow remote uninstall of the agent.");
break;
}
case 'removeuserfromdevice': {
console.log("Remove a user from a device, Example usages:\r\n");
console.log(winRemoveSingleQuotes(" MeshCtrl RemoveuserFromDeviceGroup --id 'deviceid' --userid userid"));
console.log("\r\nRequired arguments:\r\n");
if (process.platform == 'win32') {
console.log(" --id [deviceid] - The device identifier.");
} else {
console.log(" --id '[deviceid]' - The device identifier.");
}
console.log(" --userid [userid] - The user identifier.");
break;
}
case 'broadcast': {
console.log("Display a message to one or all logged in users, Example usages:\r\n");
console.log(" MeshCtrl Broadcast --msg \"This is a test\"");
console.log("\r\nRequired arguments:\r\n");
console.log(" --msg [message] - Message to display.");
console.log("\r\nOptional arguments:\r\n");
console.log(" --user [userid] - Send the message to the specified user.");
break;
}
case 'deviceinfo': {
console.log("Display information about a device, Example usages:\r\n");
console.log(winRemoveSingleQuotes(" MeshCtrl DeviceInfo --id 'deviceid'"));
console.log(winRemoveSingleQuotes(" MeshCtrl DeviceInfo --id 'deviceid' --json"));
console.log("\r\nRequired arguments:\r\n");
if (process.platform == 'win32') {
console.log(" --id [deviceid] - The device identifier.");
} else {
console.log(" --id '[deviceid]' - The device identifier.");
}
console.log("\r\nOptional arguments:\r\n");
console.log(" --raw - Output raw data in JSON format.");
console.log(" --json - Give results in JSON format.");
break;
}
case 'removedevice': {
console.log("Delete a device, Example usages:\r\n");
console.log(winRemoveSingleQuotes(" MeshCtrl RemoveDevice --id 'deviceid'"));
console.log("\r\nRequired arguments:\r\n");
if (process.platform == 'win32') {
console.log(" --id [deviceid] - The device identifier.");
} else {
console.log(" --id '[deviceid]' - The device identifier.");
}
break;
}
case 'addlocaldevice': {
console.log("Add a Local Device, Example usages:\r\n");
console.log(winRemoveSingleQuotes(" MeshCtrl AddLocalDevice --id 'meshid' --devicename 'devicename' --hostname 'hostname'"));
console.log(winRemoveSingleQuotes(" MeshCtrl AddLocalDevice --id 'meshid' --devicename 'devicename' --hostname 'hostname' --type 6"));
console.log("\r\nRequired arguments:\r\n");
if (process.platform == 'win32') {
console.log(" --id [meshid] - The mesh identifier.");
console.log(" --devicename [devicename] - The device name.");
console.log(" --hostname [hostname] - The devices hostname or ip address.");
} else {
console.log(" --id '[meshid]' - The mesh identifier.");
console.log(" --devicename '[devicename]' - The device name.");
console.log(" --hostname '[hostname]' - The devices hostname or ip address.");
}
console.log("\r\nOptional arguments:\r\n");
console.log(" --type [TypeNumber] - With the following choices:");
console.log(" type 4 - Default, Windows (RDP)");
console.log(" type 6 - Linux (SSH/SCP/VNC)");
console.log(" type 29 - macOS (SSH/SCP/VNC)");
break;
}
case 'addamtdevice': {
console.log("Add an Intel AMT Device, Example usages:\r\n");
console.log(winRemoveSingleQuotes(" MeshCtrl AddAmtDevice --id 'meshid' --devicename 'devicename' --hostname 'hostname --user 'admin' --pass 'admin'"));
console.log(winRemoveSingleQuotes(" MeshCtrl AddAmtDevice --id 'meshid' --devicename 'devicename' --hostname 'hostname --user 'admin' --pass 'admin' --notls"));
console.log("\r\nRequired arguments:\r\n");
if (process.platform == 'win32') {
console.log(" --id [meshid] - The mesh identifier.");
console.log(" --devicename [devicename] - The device name.");
console.log(" --hostname [hostname] - The devices hostname or ip address.");
console.log(" --user [user] - The devices AMT username.");
console.log(" --pass [pass] - The devices AMT password.");
console.log("")
} else {
console.log(" --id '[meshid]' - The mesh identifier.");
console.log(" --devicename '[devicename]' - The device name.");
console.log(" --hostname '[hostname]' - The devices hostname or ip address.");
console.log(" --user '[user]' - The devices AMT username.");
console.log(" --pass '[pass]' - The devices AMT password.");
}
console.log("\r\nOptional arguments:\r\n");
if (process.platform == 'win32') {
console.log(" --notls - Use No TLS Security.");
} else {
console.log(" --notls - Use No TLS Security.");
}
break;
}
case 'editdevice': {
console.log("Change information about a device, Example usages:\r\n");
console.log(winRemoveSingleQuotes(" MeshCtrl EditDevice --id 'deviceid' --name 'device1'"));
console.log("\r\nRequired arguments:\r\n");
if (process.platform == 'win32') {
console.log(" --id [deviceid] - The device identifier.");
} else {
console.log(" --id '[deviceid]' - The device identifier.");
}
console.log("\r\nOptional arguments:\r\n");
if (process.platform == 'win32') {
console.log(" --name [name] - Change device name.");
console.log(" --desc [description] - Change device description.");
console.log(" --tags [tag1,tags2] - Change device tags.");
} else {
console.log(" --name '[name]' - Change device name.");
console.log(" --desc '[description]' - Change device description.");
console.log(" --tags '[tag1,tags2]' - Change device tags.");
}
console.log(" --icon [number] - Change the device icon (1 to 8).");
console.log(" --consent [flags] - Sum of the following numbers:");
console.log(" 1 = Desktop notify 2 = Terminal notify");
console.log(" 4 = Files notify 8 = Desktop prompt");
console.log(" 16 = Terminal prompt 32 = Files prompt");
console.log(" 64 = Desktop privacy bar");
break;
}
case 'runcommand': {
console.log("Run a shell command on a remote device, Example usages:\r\n");
console.log(winRemoveSingleQuotes(" MeshCtrl RunCommand --id 'deviceid' --run \"command\""));
console.log(winRemoveSingleQuotes(" MeshCtrl RunCommand --id 'deviceid' --run \"command\" --powershell"));
console.log(winRemoveSingleQuotes(" MeshCtrl RunCommand --id 'deviceid' --run \"command\" --reply"));
console.log("\r\nRequired arguments:\r\n");
if (process.platform == 'win32') {
console.log(" --id [deviceid] - The device identifier.");
} else {
console.log(" --id '[deviceid]' - The device identifier.");
}
console.log(" --run \"[command]\" - Shell command to execute on the remote device.");
console.log("\r\nOptional arguments:\r\n");
console.log(" --powershell - Run in Windows PowerShell.");
console.log(" --runasuser - Attempt to run the command as logged in user.");
console.log(" --runasuseronly - Only run the command as the logged in user.");
console.log(" --reply - Return with the output from running the command.");
break;
}
case 'shell': {
console.log("Access a command shell on a remote device, Example usages:\r\n");
console.log(winRemoveSingleQuotes(" MeshCtrl Shell --id 'deviceid'"));
console.log(winRemoveSingleQuotes(" MeshCtrl Shell --id 'deviceid' --powershell"));
console.log("\r\nRequired arguments:\r\n");
if (process.platform == 'win32') {
console.log(" --id [deviceid] - The device identifier.");
} else {
console.log(" --id '[deviceid]' - The device identifier.");
}
console.log("\r\nOptional arguments:\r\n");
console.log(" --powershell - Run a Windows PowerShell.");
break;
}
case 'devicepower': {
console.log("Perform power operations on remote devices, Example usages:\r\n");
console.log(winRemoveSingleQuotes(" MeshCtrl DevicePower --wake --id 'deviceid'"));
console.log(winRemoveSingleQuotes(" MeshCtrl DevicePower --sleep --id 'deviceid'"));
console.log(winRemoveSingleQuotes(" MeshCtrl DevicePower --reset --id 'deviceid'"));
console.log(winRemoveSingleQuotes(" MeshCtrl DevicePower --off --id 'deviceid1,deviceid2'"));
console.log("\r\nNote that some power operations may take up to a minute to execute.\r\n");
console.log("Required arguments:\r\n");
if (process.platform == 'win32') {
console.log(" --id [deviceid1,deviceid2] - Device identifiers.");
} else {
console.log(" --id '[deviceid1,deviceid2]' - Device identifiers.");
}
console.log("\r\nOptional arguments:\r\n");
console.log(" --wake - Attempt to wake up the remote device.");
console.log(" --reset - Attempt to remote the remote device.");
console.log(" --sleep - Attempt to place the remote device in low power mode.");
console.log(" --off - Attempt to power off the remote device.");
console.log(" --amtoff - Attempt to power off the remote device using Intel AMT.");
console.log(" --amton - Attempt to power on the remote device using Intel AMT.");
console.log(" --amtreset - Attempt to reset the remote device using Intel AMT.");
break;
}
case 'devicesharing': {
var tzoffset = (new Date()).getTimezoneOffset() * 60000; // Offset in milliseconds
var localISOTime = (new Date(Date.now() - tzoffset)).toISOString().slice(0, -5);
console.log("List sharing links for a specified device, Example usages:\r\n");
console.log(winRemoveSingleQuotes(" MeshCtrl DeviceSharing --id 'deviceid'"));
console.log(winRemoveSingleQuotes(" MeshCtrl DeviceSharing --id 'deviceid' --remove abcdef"));
console.log(winRemoveSingleQuotes(" MeshCtrl DeviceSharing --id 'deviceid' --add Guest --start " + localISOTime + " --duration 30"));
console.log(winRemoveSingleQuotes(" MeshCtrl DeviceSharing --id 'deviceid' --add Guest --start " + localISOTime + " --duration 30 --daily"));
console.log(winRemoveSingleQuotes(" MeshCtrl DeviceSharing --id 'deviceid' --add Guest --type desktop,terminal --consent prompt"));
console.log(winRemoveSingleQuotes(" MeshCtrl DeviceSharing --id 'deviceid' --add Guest --type http --port 80"));
console.log("\r\nRequired arguments:\r\n");
if (process.platform == 'win32') {
console.log(" --id [deviceid] - The device identifier.");
} else {
console.log(" --id '[deviceid]' - The device identifier.");
}
console.log("\r\nOptional arguments:\r\n");
console.log(" --remove [shareid] - Remove a device sharing link.");
console.log(" --add [guestname] - Add a device sharing link.");
console.log(" --type [desktop,terminal,files,http,https] - Type of sharing to add, can be combined. default is desktop.");
console.log(" --viewonly - Make desktop sharing view only.");
console.log(" --consent [notify,prompt,none] - Consent flags, default is notify.");
console.log(" --start [yyyy-mm-ddThh:mm:ss] - Start time, default is now.");
console.log(" --end [yyyy-mm-ddThh:mm:ss] - End time.");
console.log(" --duration [minutes] - Duration of the share, default is 60 minutes.");
console.log(" --daily - Add recurring daily device share.");
console.log(" --weekly - Add recurring weekly device share.");
console.log(" --port [portnumber] - Set alternative port for http or https, default is 80 for http and 443 for https.");
break;
}
case 'agentdownload': {
console.log("Download an agent of a specific type for a given device group, Example usages:\r\n");
console.log(winRemoveSingleQuotes(" MeshCtrl AgentDownload --id 'groupid' --type 3"));
console.log(winRemoveSingleQuotes(" MeshCtrl AgentDownload --id 'groupid' --type 3 --installflags 1"));
console.log("\r\nRequired arguments:\r\n");
console.log(" --type [ArchitectureNumber] - Agent architecture number.");
if (process.platform == 'win32') {
console.log(" --id [groupid] - The device group identifier.");
} else {
console.log(" --id '[groupid]' - The device group identifier.");
}
console.log("\r\nOptional arguments:\r\n");
console.log(" --installflags [InstallFlagsNumber] - With the following choices:");
console.log(" installflags 0 - Default, Interactive & Background, offers connect button & install/uninstall");
console.log(" installflags 1 - Interactive only, offers only connect button, not install/uninstall");
console.log(" installflags 2 - Background only, offers only install/uninstall, not connect");
break;
}
case 'upload': {
console.log("Upload a local file to a remote device, Example usages:\r\n");
console.log(winRemoveSingleQuotes(" MeshCtrl Upload --id 'deviceid' --file sample.txt --target c:\\"));
console.log(winRemoveSingleQuotes(" MeshCtrl Upload --id 'deviceid' --file sample.txt --target /tmp"));
console.log("\r\nRequired arguments:\r\n");