|
| 1 | +var StatefulProcessCommandProxy = require("stateful-process-command-proxy"); |
| 2 | +var PSCommandService = require('./psCommandService'); |
| 3 | +var o365Utils = require('./o365Utils'); |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | +var statefulProcessCommandProxy = new StatefulProcessCommandProxy({ |
| 9 | + name: "StatefulProcessCommandProxy", |
| 10 | + max: 1, |
| 11 | + min: 1, |
| 12 | + idleTimeoutMS:120000, |
| 13 | + log: function(severity,origin,msg) { |
| 14 | + console.log(severity.toUpperCase() + " " +origin+" "+ msg); |
| 15 | + }, |
| 16 | + |
| 17 | + processCommand: 'C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe', |
| 18 | + processArgs: ['-Command','-'], |
| 19 | + |
| 20 | + |
| 21 | + processRetainMaxCmdHistory : 20, |
| 22 | + processInvalidateOnRegex : { |
| 23 | + 'any':[], |
| 24 | + 'stdout':[], |
| 25 | + 'stderr':[{'regex':'.*error.*'}] |
| 26 | + }, |
| 27 | + processCwd : null, |
| 28 | + processEnvMap : null, |
| 29 | + processUid : null, |
| 30 | + processGid : null, |
| 31 | + |
| 32 | + initCommands: o365Utils.getO365PSThumbprintInitCommands( |
| 33 | + 'C:\\pathto\\decryptUtil.ps1', |
| 34 | + 'C:\\pathto\\encrypted.credentials', |
| 35 | + 'C:\\pathto\\secret.key', |
| 36 | + 'certificatethumbprint', |
| 37 | + '00000000-00000000-00000000-00000000', |
| 38 | + 'your.exhange.domain.name', |
| 39 | + 10000,30000,60000), |
| 40 | + |
| 41 | + |
| 42 | + validateFunction: function(processProxy) { |
| 43 | + var isValid = processProxy.isValid(); |
| 44 | + if(!isValid) { |
| 45 | + console.log("ProcessProxy.isValid() returns FALSE!"); |
| 46 | + } |
| 47 | + return isValid; |
| 48 | + }, |
| 49 | + |
| 50 | + |
| 51 | + preDestroyCommands: o365Utils.getO365PSThumbprintDestroyCommands(), |
| 52 | + |
| 53 | + processCmdWhitelistRegex: o365Utils.getO365WhitelistedCommands(), |
| 54 | + |
| 55 | + processCmdBlacklistRegex: o365Utils.getO365BlacklistedCommands(), |
| 56 | + |
| 57 | + autoInvalidationConfig: o365Utils.getO365AutoInvalidationConfig(30000) |
| 58 | + |
| 59 | +}); |
| 60 | + |
| 61 | +var myLogFunction = function(severity,origin,message) { |
| 62 | + console.log(severity.toUpperCase() + ' ' + origin + ' ' + message); |
| 63 | +} |
| 64 | + |
| 65 | + |
| 66 | +/** |
| 67 | +* Fetch a group! |
| 68 | +*/ |
| 69 | +var psCommandService = new PSCommandService(statefulProcessCommandProxy, |
| 70 | + o365Utils.o365CommandRegistry, |
| 71 | + myLogFunction); |
| 72 | + |
| 73 | +psCommandService.execute('getDistributionGroup',{'Identity':"someGroupName"}) |
| 74 | + .then(function(groupJson) { |
| 75 | + console.log(groupJson); |
| 76 | + }).catch(function(error) { |
| 77 | + console.log(error); |
| 78 | + }); |
| 79 | + |
| 80 | +setTimeout(function(){statefulProcessCommandProxy.shutdown()},80000); |
0 commit comments