-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSiebel-IP19-Module.psm1
563 lines (491 loc) · 28.9 KB
/
Siebel-IP19-Module.psm1
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
## ************************************** ##
## Siebel IP29+ Powershell Module 2020/01 ##
## ************************************** ##
## Import-Module -FullyQualifiedName "Siebel-IP19-Module.psm1"
## remove-module Siebel-IP19-Module.psm1
## Defaults ##
$SBLAppIntPath = "d:\Oracle\Siebel\ai"
$SBLGtwyPath = "d:\Oracle\Siebel\gw\gtwysrvr"
$SBLSrvrPath = "d:\Oracle\Siebel\ses\SiebSrvr"
$SBLTempPath = "c:\Temp\"
$SBLGtwyServer = "xx.yy.com"
[string[]] $SBLServers = "xx.yy.com"
$SBLClientPath = "C:\Oracle\Siebel\16.0.0.0.0\Client"
## Turn off Certificate check for Siebel selfsigned Cert
if (-not ([System.Management.Automation.PSTypeName]'ServerCertificateValidationCallback').Type)
{
$certCallback = @"
using System;
using System.Net;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
public class ServerCertificateValidationCallback
{
public static void Ignore()
{
if(ServicePointManager.ServerCertificateValidationCallback ==null)
{
ServicePointManager.ServerCertificateValidationCallback +=
delegate
(
Object obj,
X509Certificate certificate,
X509Chain chain,
SslPolicyErrors errors
)
{
return true;
};
}
}
}
"@
Add-Type $certCallback
}
[ServerCertificateValidationCallback]::Ignore()
## Set Env
function Set-SBLEnv {
param ([ValidateSet('Rep','Dev','QA','PProd','Prd-DP','Prd-CM','Prd')][string[]]$Env = ("QA"),
[switch]$Verbose)
switch ($Env) {
"Rep" {
$global:SBLHost = "siebel.yy.com"
$global:SBLGtwyServer = "mm"
$global:SBLAIServers = "mm"
$global:SBLServers = "mm"
$global:SBLAllServers = "mm"
$global:SBLGtwyPath = "d:\Oracle\Siebel\gw\gtwysrvr"
Break
}
"Dev" {
$global:SBLHost = "siebel.yy.com"
$global:SBLGtwyServer = "mm"
$global:SBLAIServers = "mm"
$global:SBLServers = "mm"
$global:SBLAllServers = "mm"
$global:SBLGtwyPath = "d:\Oracle\Siebel\gw\gtwysrvr"
Break
}
"QA" {
$global:SBLHost = "siebel.yy.com"
$global:SBLGtwyServer = "mm"
$global:SBLAIServers = "mm"
$global:SBLServers = "mm"
$global:SBLAllServers = "mm"
$global:SBLGtwyPath = "d:\Oracle\Siebel\gw\gtwysrvr"
Break
}
"PProd" {
$global:SBLHost = "siebel.yy.com"
$global:SBLGtwyServer = "mm"
$global:SBLAIServers = "mm"
$global:SBLServers = "mm"
$global:SBLAllServers = "mm"
$global:SBLGtwyPath = "d:\Oracle\Siebel\gw\gtwysrvr"
Break
}
"Prd" {
$global:SBLHost = "siebel.yy.com"
$global:SBLGtwyServer = "mm"
$global:SBLAIServers = "mm"
$global:SBLServers = "mm"
$global:SBLAllServers = "mm"
$global:SBLGtwyPath = "d:\Oracle\Siebel\gs\gtwysrvr"
Break
}
"Prd-DP" {
$global:SBLHost = "siebel.yy.com"
$global:SBLGtwyServer = "mm"
$global:SBLAIServers = "mm"
$global:SBLServers = "mm"
$global:SBLAllServers = "mm"
$global:SBLGtwyPath = "d:\Oracle\Siebel\gs\gtwysrvr"
Break
}
"Prd-CM" {
$global:SBLHost = "siebel.yy.com"
$global:SBLGtwyServer = "mm"
$global:SBLAIServers = "mm"
$global:SBLServers = "mm"
$global:SBLAllServers = "mm"
$global:SBLGtwyPath = "d:\Oracle\Siebel\gs\gtwysrvr"
Break
}
}
Write-Verbose -Message ("Siebel Host '$($global:SBLHost)'") -Verbose:$Verbose
Write-Verbose -Message ("Siebel Gtwy Path '$($global:SBLGtwyPath)'") -Verbose:$Verbose
Write-Verbose -Message ("Siebel Gtwy Server '$($global:SBLGtwyServer)'") -Verbose:$Verbose
Write-Verbose -Message ("Siebel AI Servers '$($global:SBLAIServers)'") -Verbose:$Verbose
Write-Verbose -Message ("Siebel Servers '$($global:SBLServers)'") -Verbose:$Verbose
Write-Verbose -Message ("Siebel Servers (All) '$($global:SBLAllServers)'") -Verbose:$Verbose
}
## Invoke Siebel WFP
function Invoke-SBLWFP {
param ([string]$Host = $global:SBLHost,
[string]$WFPName,
[string]$Parameters,
[Management.Automation.PSCredential]$Credential,
[switch]$Verbose)
$URI = ("https://{0}/siebel/v1.0/service/Workflow Process Manager/RunProcess?ProcessName={1}&{2}" -f $Host, $WFPName, $Parameters)
$Result = Invoke-WebRequest -Uri $URI -ContentType application/json -Method POST -Credential $Credential -Verbose:$Verbose
return $Result
}
## Stop Siebel Server Service ##
function Stop-SBLServer {
param ([string[]]$Servers = $global:SBLServers,
[Management.Automation.PSCredential]$Credential,
[switch]$Verbose)
Write-Verbose -Message ("Stoping Siebel Service(s) on '{0}'" -f $Servers) -Verbose:$Verbose
Invoke-Command -ComputerName $Servers -ScriptBlock { stop-service -InputObject $(get-Service | where {$_.Name -like 'SiebSrvr_Siebel*'}) } -Credential $Credential -Verbose:$Verbose
}
## Start Siebel Server Service ##
function Start-SBLServer {
param ([string[]]$Servers = $global:SBLServers,
[Management.Automation.PSCredential]$Credential,
[switch]$Verbose)
Write-Verbose -Message ("Start Siebel Service(s) on '{0}'" -f $Servers) -Verbose:$Verbose
Invoke-Command -ComputerName $Servers -ScriptBlock { start-service -InputObject $(get-Service | where {$_.Name -like 'siebSrvr_Siebel*'}) } -Credential $Credential -Verbose:$Verbose
}
function Get-SBLServer {
param ([string[]]$Servers = $global:SBLServers,
[Management.Automation.PSCredential]$Credential)
Invoke-Command -ComputerName $Servers -ScriptBlock { get-Service | where {$_.Name -like 'siebSrvr_Siebel*'} } -Credential $Credential
}
## Remove Siebel Server Service ##
function Remove-SBLService {
param ([string[]]$Servers = $global:SBLServers,
[string]$Path = $SBLSrvrPath,
[Management.Automation.PSCredential]$Credential,
[switch]$Verbose)
$lSrvrCmd01 = "{0}\bin\siebctl.exe -d -S siebsrvr -i ""SIEBEL_{1}"""
foreach ($Server in $Servers) {
$Service = ($Server -replace "ZA", "").ToLower()
Write-Verbose -Message ("Removing Siebel service on '{0}'" -f $Server.ToLower()) -Verbose:$Verbose
Invoke-Command -ComputerName $Server -ScriptBlock ([Scriptblock]::Create(($lSrvrCmd01 -f $Path,$Service))) -Credential $Credential -Verbose:$Verbose
}
}
## Add Siebel Server Service ##
function Add-SBLService {
param ([string[]]$Servers = $global:SBLServers,
[string]$GatewayServer = $global:SBLGtwyServer,
[string]$Path = $SBLSrvrPath,
[string]$NewPassword,
[Management.Automation.PSCredential]$Credential,
[string]$ServiceUser,
[string]$ServiceUserPassword,
[switch]$Verbose)
foreach ($Server in $Servers) {
$Service = ($Server -replace "ZA", "").ToLower()
Write-Verbose -Message ("Adding Siebel Services on '{0}' for {1}" -f $Server,$Service) -Verbose:$Verbose
if ($ServiceUserPassword) {
$lSrvrCmd02 = "{0}\bin\siebctl.exe -h {0} -S siebsrvr -i ""SIEBEL_{1}"" -a -g ""-g {2}:9999 -e SIEBEL -s {1} -l enu -u SADMIN"" -e ""{3}"" -u {4} -p ""{3}"""
Write-Verbose -Message ($lSrvrCmd02 -f $Path,$Server,$GatewayServer,$NewPassword,$ServiceUser,$ServiceUserPassword) -Verbose:$Verbose
Invoke-Command -ComputerName $Server -ScriptBlock ([Scriptblock]::Create(($lSrvrCmd02 -f $Path,$Service,$GatewayServer.ToLower(),$NewPassword,$ServiceUser,$ServiceUserPassword))) -Credential $Credential -Verbose:$Verbose
} else {
$lSrvrCmd02 = "{0}\bin\siebctl.exe -h {0} -S siebsrvr -i ""SIEBEL_{1}"" -a -g ""-g {2}:9999 -e SIEBEL -s {1} -l enu -u SADMIN"" -e ""{3}"""
Write-Verbose -Message ($lSrvrCmd02 -f $Path,$Server,$GatewayServer,$NewPassword) -Verbose:$Verbose
Invoke-Command -ComputerName $Server -ScriptBlock ([Scriptblock]::Create(($lSrvrCmd02 -f $Path,$Service,$GatewayServer.ToLower(),$NewPassword))) -Credential $Credential -Verbose:$Verbose
}
Invoke-Command -ComputerName $Server -ScriptBlock { set-service -InputObject $(get-Service | where {$_.Name -like 'SiebSrvr_Siebel*'}) -StartupType Automatic } -Credential $Credential -Verbose:$Verbose
}
}
## Backup Siebel Gateway siebns.dat file ##
function Backup-SBLGtwy {
param ([string]$GatewayServer = $global:SBLGtwyServer,
[string]$Path = $global:SBLGtwyPath,
[Management.Automation.PSCredential]$Credential,
[switch]$Verbose)
Write-Verbose -Message "Gateway backing up zookeaper." -Verbose:$Verbose
Invoke-Command -ComputerName $GatewayServer -ScriptBlock ([Scriptblock]::Create(("Compress-Archive -Path {0}\zookeeper\version-2 -DestinationPath {0}\zookeeper\version-2_{1}.zip -Force -Verbose" -f $Path,$(get-date -f yyyy-MM-dd)))) -Credential $Credential -Verbose:$Verbose
}
function Stop-SBLGtwyServer {
param ([string[]]$Servers = $global:SBLGtwyServer,
[Management.Automation.PSCredential]$Credential,
[switch]$Verbose)
Write-Verbose -Message ("Stoping Siebel Gateway Service on '{0}'" -f $Servers) -Verbose:$Verbose
Invoke-Command -ComputerName $Servers -ScriptBlock { stop-service -InputObject $(get-Service | where {$_.Name -like 'gtwyns'}) } -Credential $Credential -Verbose:$Verbose
}
## Start Siebel Server Service ##
function Start-SBLGtwyServer {
param ([string[]]$Servers = $global:SBLGtwyServer,
[Management.Automation.PSCredential]$Credential,
[switch]$Verbose)
Write-Verbose -Message ("Start Siebel Gateway Service on '{0}'" -f $Servers) -Verbose:$Verbose
Invoke-Command -ComputerName $Servers -ScriptBlock { start-service -InputObject $(get-Service | where {$_.Name -like 'gtwyns'}) } -Credential $Credential -Verbose:$Verbose
}
function Get-SBLGtwyServer {
param ([string[]]$Servers = $global:SBLGtwyServer,
[Management.Automation.PSCredential]$Credential)
Invoke-Command -ComputerName $Servers -ScriptBlock { get-Service | where {$_.Name -like 'gtwyns'} } -Credential $Credential
}
## Change Siebel Gateway Enterprize Paramiter ##
function Set-SBLGtwyEnvParam {
param ([string]$Name,
[string]$Value,
[string]$GatewayServer = $global:SBLGtwyServer,
[string]$Path = $global:SBLGtwyPath,
[string]$Password,
[Management.Automation.PSCredential]$Credential,
[switch]$Verbose)
$lGtwyCmd = '{0}\BIN\srvrmgr.exe -g {1} -e siebel -u sadmin -p "{2}" -c "change ent param {3}=""{4}"""'
Write-Verbose -Message "Gateway update enterpize paramiter $Name." -Verbose:$Verbose
Invoke-Command -ComputerName $GatewayServer -ScriptBlock ([Scriptblock]::Create(($lGtwyCmd -f $Path,$GatewayServer,$Password,$Name,$Value))) -Credential $Credential -Verbose:$Verbose
}
## Change Siebel Gateway SybStstem Paramiter ##
function Set-SBLGtwySubSysParam {
param ([string]$Name,
[string]$Value,
[string[]]$SybSystems,
[string]$GatewayServer = $global:SBLGtwyServer,
[string]$ComputerName = $global:SBLGtwyServer,
[string]$Path = $global:SBLGtwyPath,
[string]$Password,
[Management.Automation.PSCredential]$Credential,
[switch]$Verbose)
$lGtwyCmd01 = '{0}\BIN\srvrmgr.exe -g {1} -e siebel -u sadmin -p "{2}" -c "change param {3}=""{4}"" for named subsystem {5}"'
foreach ($SybSystem in $SybSystems) {
Write-Verbose -Message ("Gateway update SubSystem paramiter '{0}' for '{1}'." -f $Name,$SybSystem)
Invoke-Command -ComputerName $ComputerName -ScriptBlock ([Scriptblock]::Create(($lGtwyCmd01 -f $Path,$GatewayServer,$Password,$Name,$Value,$SybSystem))) -Credential $Credential -Verbose:$Verbose
}
}
## Change Siebel Gateway SybSystem Paramiter ##
function Get-SBLGtwyEvtLogLevel {
param ([ValidateSet("CommInboundRcvr","EIM","CustomAppObjMgr_enu","eCommunicationsObjMgr_enu","eProdCfgObjMgr_enu","EAIObjMgr_enu","PRMPortal_enu","VCVPPObjMgr_enu","VCDHAObjMgr_enu","VCEAIQWfProcMgr","VCIFObjMgr_enu","VCIFTObjMgr_enu","WfProcMgr","WfProcBatchMgr","AsgnSrvr","XMLPReportServer","CommInboundProcessor")][string]$CompAliasName,
[string]$GatewayServer = $global:SBLGtwyServer,
[string]$Path = $global:SBLGtwyPath,
[string]$Password,
[Management.Automation.PSCredential]$Credential,
[switch]$Verbose)
if ($Server) {
$lGtwyCmd01 = '{0}\BIN\srvrmgr.exe -g {1} -e siebel -u SADMIN -p "{2}" -c "list evtloglvl for server {3} component {4}"'
Write-Verbose -Message ("Gateway: Get Event logging level for server '{0}', compoment '{1}'." -f $Server,$CompAliasName) -Verbose:$Verbose
Invoke-Command -ComputerName $GatewayServer -ScriptBlock ([Scriptblock]::Create(($lGtwyCmd01 -f $Path,$GatewayServer,$Password,$Server,$CompAliasName))) -Credential $Credential -Verbose:$Verbose
} else {
$lGtwyCmd01 = '{0}\BIN\srvrmgr.exe -g {1} -e siebel -u SADMIN -p "{2}" -c "list evtloglvl for component {3}"'
Write-Verbose -Message ("Gateway: Get Event logging level for compoment '{0}'." -f $CompAliasName) -Verbose:$Verbose
Invoke-Command -ComputerName $GatewayServer -ScriptBlock ([Scriptblock]::Create(($lGtwyCmd01 -f $Path,$GatewayServer,$Password,$CompAliasName))) -Credential $Credential -Verbose:$Verbose
}
}
function Set-SBLGtwyEvtLogLevel {
param ([string]$Name = "%",
[ValidateSet("0","1","2","3","4","5")][string]$Value = "1",
[ValidateSet("CommInboundRcvr","EIM","CustomAppObjMgr_enu","eCommunicationsObjMgr_enu","eProdCfgObjMgr_enu","EAIObjMgr_enu","EAIObjMgrOTP_enu", "eChannelObjMgr_enu","eChannelObjMgrAD_enu","VCVPPObjMgr_enu","VCIFObjMgr_enu","VCIFTObjMgr_enu","VCDHAObjMgr_enu","VCEAIQWfProcMgr","WfProcMgr","WfProcBatchMgr","AsgnSrvr","XMLPReportServer","CommInboundProcessor")][string]$CompAliasName,
[string]$Server,
[string]$GatewayServer = $global:SBLGtwyServer,
[string]$Path = $global:SBLGtwyPath,
[string]$Password,
[Management.Automation.PSCredential]$Credential,
[switch]$Verbose)
if ($Server) {
$lGtwyCmd01 = '{0}\BIN\srvrmgr.exe -g {1}:9999 -e siebel -u SADMIN -p "{2}" -c "change evtloglvl {3}={4} for server {5} component {6}"'
Write-Verbose -Message ("Gateway: change evtloglvl {0}={1} for server {2} component {3}." -f $Name,$Value,$Server,$CompAliasName) -Verbose:$Verbose
Invoke-Command -ComputerName $GatewayServer -ScriptBlock ([Scriptblock]::Create(($lGtwyCmd01 -f $Path,$GatewayServer,$Password,$Name,$Value,$Server,$CompAliasName))) -Credential $Credential -Verbose:$Verbose
} else {
$lGtwyCmd01 = '{0}\BIN\srvrmgr.exe -g {1}:9999 -e siebel -u SADMIN -p "{2}" -c "change evtloglvl {3}={4} for component {5}"'
Write-Verbose -Message ("Gateway: change evtloglvl {0}={1} for component {2}." -f $Name,$Value,$CompAliasName) -Verbose:$Verbose
Invoke-Command -ComputerName $GatewayServer -ScriptBlock ([Scriptblock]::Create(($lGtwyCmd01 -f $Path,$GatewayServer,$Password,$Name,$Value,$CompAliasName))) -Credential $Credential -Verbose:$Verbose
}
}
function Set-SBLSrvrComp {
param ([ValidateSet("CustomAppObjMgr_enu","eCommunicationsObjMgr_enu","eProdCfgObjMgr_enu","EAIObjMgr_enu","EAIObjMgrOTP_enu", "eChannelObjMgr_enu","eChannelObjMgrAD_enu","VCVPPObjMgr_enu","VCIFTObjMgr_enu","VCIFObjMgr_enu","VCDHAObjMgr_enu","VCEAIQWfProcMgr","WfProcMgr","WfProcBatchMgr","AsgnSrvr","XMLPReportServer","CommInboundProcessor")][string]$CompAliasName,
[ValidateSet("Startup","Kill","Shutdown")][string]$Command,
[string]$Server,
[string]$GatewayServer = $global:SBLGtwyServer,
[string]$Path = $global:SBLGtwyPath,
[string]$Password,
[Management.Automation.PSCredential]$Credential,
[switch]$Verbose)
if ($Server) {
$lGtwyCmd01 = '{0}\BIN\srvrmgr.exe -g {1} -e siebel -u sadmin -p "{2}" -c "{3} comp {4} for server {5}"'
Write-Verbose -Message ("SiebelServer: {0} comp '{1}' for server '{2}'." -f $Command,$CompAliasName,$Server) -Verbose:$Verbose
Invoke-Command -ComputerName $GatewayServer -ScriptBlock ([Scriptblock]::Create(($lGtwyCmd01 -f $Path,$GatewayServer,$Password,$Command,$CompAliasName,$Server))) -Credential $Credential -Verbose:$Verbose
} else {
$lGtwyCmd01 = '{0}\BIN\srvrmgr.exe -g {1} -e siebel -u sadmin -p "{2}" -c "{3} comp {4}"'
Write-Verbose -Message ("SiebelServer: {0} compoment '{1}'." -f $Command,$CompAliasName) -Verbose:$Verbose
Invoke-Command -ComputerName $GatewayServer -ScriptBlock ([Scriptblock]::Create(($lGtwyCmd01 -f $Path,$GatewayServer,$Password,$Command,$CompAliasName))) -Credential $Credential -Verbose:$Verbose
}
}
function Get-SBLSrvrComp {
param ([ValidateSet("CustomAppObjMgr_enu","eCommunicationsObjMgr_enu","eProdCfgObjMgr_enu","EAIObjMgr_enu", "EAIObjMgrOTP_enu", "eChannelObjMgr_enu","eChannelObjMgrAD_enu","VCVPPObjMgr_enu","VCIFTObjMgr_enu","VCIFObjMgr_enu","VCDHAObjMgr_enu","VCEAIQWfProcMgr","WfProcMgr","WfProcBatchMgr","AsgnSrvr","XMLPReportServer","CommInboundProcessor")][string]$CompAliasName,
[string]$Server,
[string]$GatewayServer = $global:SBLGtwyServer,
[string]$Path = $global:SBLGtwyPath,
[string]$Password,
[Management.Automation.PSCredential]$Credential,
[switch]$Verbose)
if ($Server) {
$lGtwyCmd01 = '{0}\BIN\srvrmgr.exe -g {1} -e siebel -u sadmin -p "{2}" -c "list comp {3} for server {4}"'
Write-Verbose -Message ("SiebelServer: list comp '{0}' for server '{1}'." -f $CompAliasName,$Server) -Verbose:$Verbose
Invoke-Command -ComputerName $GatewayServer -ScriptBlock ([Scriptblock]::Create(($lGtwyCmd01 -f $Path,$GatewayServer,$Password,$CompAliasName,$Server))) -Credential $Credential -Verbose:$Verbose
} else {
$lGtwyCmd01 = '{0}\BIN\srvrmgr.exe -g {1} -e siebel -u sadmin -p "{2}" -c "list comp {3}"'
Write-Verbose -Message ("SiebelServer: list compoment '{0}'." -f $CompAliasName) -Verbose:$Verbose
Invoke-Command -ComputerName $GatewayServer -ScriptBlock ([Scriptblock]::Create(($lGtwyCmd01 -f $Path,$GatewayServer,$Password,$CompAliasName))) -Credential $Credential -Verbose:$Verbose
}
}
function Get-SBLSrvrLogs {
param ([ValidateSet('Log','Temp','FDR','Crash')][string[]]$Types = ("Log"),
[string]$Filter = "*",
[string]$Pattern,
[string[]]$Servers = $global:SBLServers,
[string]$Destination = $SBLTempPath,
[Management.Automation.PSCredential]$Credential,
[switch]$Verbose)
$Sessions = New-PSSession -ComputerName $Servers -Credential $Credential
$Path = "{0}\{1}\{2}.{3}"
foreach ($Type in $Types) {
foreach ($Session in $Sessions) {
Write-Verbose -Message ("Remote Server: {0}." -f $Session.ComputerName) -Verbose:$Verbose
switch ($Type) {
"Log" {
Write-Verbose -Message "Getting file from '\Log'." -Verbose:$Verbose
if ($Pattern) {
$Temp = "Get-Item {0} | select-string -list -pattern {1} | group path |select name"
$Files = Invoke-Command -Session $Session -ScriptBlock ([Scriptblock]::Create(($Temp -f ($Path -f $SBLSrvrPath,"log",$Filter,"log"),$Pattern))) -Verbose:$Verbose
foreach ($File in $Files) {
Copy-Item $File.Name -Force -Destination $Destination -FromSession $Session -Verbose:$Verbose -ErrorAction SilentlyContinue
}
} else {
Copy-Item ($Path -f $SBLSrvrPath,"log",$Filter,"log") -Force -Destination $Destination -FromSession $Session -Verbose:$Verbose -ErrorAction SilentlyContinue
}
Break;
}
"Temp" {
Write-Verbose -Message "Getting file from '\TEMP'." -Verbose:$Verbose
Copy-Item ($Path -f $SBLSrvrPath,"TEMP",$Filter,"csv") -Force -Destination $Destination -FromSession $Session -Verbose:$Verbose -ErrorAction SilentlyContinue
Copy-Item ($Path -f $SBLSrvrPath,"TEMP",$Filter,"tmp") -Force -Destination $Destination -FromSession $Session -Verbose:$Verbose -ErrorAction SilentlyContinue
Copy-Item ($Path -f $SBLSrvrPath,"TEMP",$Filter,"xml") -Force -Destination $Destination -FromSession $Session -Verbose:$Verbose -ErrorAction SilentlyContinue
Copy-Item ($Path -f $SBLSrvrPath,"TEMP",$Filter,"ini") -Force -Destination $Destination -FromSession $Session -Verbose:$Verbose -ErrorAction SilentlyContinue
Copy-Item ($Path -f $SBLSrvrPath,"TEMP",$Filter,"pdf") -Force -Destination $Destination -FromSession $Session -Verbose:$Verbose -ErrorAction SilentlyContinue
Break
}
"FDR" {
Write-Verbose -Message "Getting file from '\FDR'." -Verbose:$Verbose
$Cmd = "{0}\bin\sarmanalyzer.exe -f {0}\BIN\{1} -x -o {0}\temp\{1}.csv";
$Temp = "Get-Item {0}\BIN\{1}.fdr"
$Files = Invoke-Command -Session $Session -ScriptBlock ([Scriptblock]::Create(($Temp -f $SBLSrvrPath,$Filter))) -Verbose:$Verbose
foreach ($File in $Files) {
Write-Verbose -Message ("Converting: {0}" -f $File.Name) -Verbose:$Verbose
Invoke-Command -Session $Session -ScriptBlock ([Scriptblock]::Create(($Cmd -f $SBLSrvrPath,$File.Name))) -Verbose:$Verbose
Copy-Item ($Path -f $SBLSrvrPath,"Temp",$File.Name,"csv") -Destination $Destination -FromSession $Session -Verbose:$Verbose -ErrorAction SilentlyContinue
}
Break
}
"Crash" {
Write-Verbose -Message "Getting file from '\Crash'." -Verbose:$Verbose
$Temp = "crash_" + $Filter
Copy-Item ($Path -f $SBLSrvrPath,"BIN",$Temp,"txt") -Destination $Destination -FromSession $Session -Verbose -ErrorAction SilentlyContinue
Break
}
##"LOGARCHIVE" {
## Write-Verbose -Message "Getting file from '\LOGARCHIVE'." -Verbose:$Verbose
## Copy-Item ($Path -f $SBLSrvrPath,"LOGARCHIVE",$Filter,"log") -Destination $Destination -FromSession $Session -Verbose -ErrorAction SilentlyContinue
## Break;
##}
}
}
}
Remove-PSSession $Sessions
}
function Remove-SBLSrvrLogs {
param ([ValidateSet('AI','EmailResponce','Log','Temp','FDR','Crash','LOGARCHIVE','DRCache')][string[]]$Types = ("EmailResponce","Log","Temp","FDR","Crash","LOGARCHIVE"),
[string]$Filter = "*",
[string[]]$Servers = $global:SBLServers,
[Management.Automation.PSCredential][System.Management.Automation.Credential()]$Credential,
[int32]$AddMin = 0,
[switch]$Verbose)
$Sessions = New-PSSession -ComputerName $Servers -Credential $Credential
if ($Verbose) {
$Command = "Get-ChildItem ""{0}\{1}\*"" -Include {2}.{3} | Where-Object LastWriteTime -lt (Get-Date).AddMinutes({4} | Remove-Item -ErrorAction SilentlyContinue -Verbose"
$Command1 = "Get-ChildItem ""{0}\{1}\*"" -Include {2}.{3} -Recurse | Where-Object LastWriteTime -lt (Get-Date).AddMinutes({4}) | Remove-Item -ErrorAction SilentlyContinue -Verbose"
} else {
$Command = "Get-ChildItem ""{0}\{1}\*"" -Include {2}.{3} | Where-Object LastWriteTime -lt (Get-Date).AddMinutes({4}) | Remove-Item -ErrorAction SilentlyContinue"
$Command1 = "Get-ChildItem ""{0}\{1}\*"" -Include {2}.{3} -Recurse | Where-Object LastWriteTime -lt (Get-Date).AddMinutes({4}) | Remove-Item -ErrorAction SilentlyContinue"
}
$AddMin = $AddMin * -1;
foreach ($Type in $Types) {
switch ($Type) {
"AI" {
Write-Verbose -Message "Removing '\AI Log' files." -Verbose:$Verbose
Invoke-Command -Session $Sessions -ScriptBlock ([Scriptblock]::Create(($Command -f $SBLAppIntPath,"applicationcontainer\logs",$Filter,"*",$AddMin)))
Break
}
"EmailResponce" {
Write-Verbose -Message "Removing '\Email Responce (processing\incomming)' files." -Verbose:$Verbose
Invoke-Command -Session $Sessions -ScriptBlock ([Scriptblock]::Create(($Command -f $SBLSrvrPath,"BIN\processed",$Filter,"*",$AddMin)))
Invoke-Command -Session $Sessions -ScriptBlock ([Scriptblock]::Create(($Command -f $SBLSrvrPath,"BIN\incoming",$Filter,"*",$AddMin)))
Break
}
"Log" {
Write-Verbose -Message "Removing '\Log' files." -Verbose:$Verbose
Invoke-Command -Session $Sessions -ScriptBlock ([Scriptblock]::Create(($Command -f $SBLSrvrPath,"log",$Filter,"log",$AddMin)))
Invoke-Command -Session $Sessions -ScriptBlock ([Scriptblock]::Create(($Command -f $SBLSrvrPath,"log",$Filter,"dmp",$AddMin)))
Break;
}
"Temp" {
Write-Verbose -Message "Removing '\Temp' files." -Verbose:$Verbose
Invoke-Command -Session $Sessions -ScriptBlock ([Scriptblock]::Create(($Command2 -f $SBLSrvrPath,"TEMP",$Filter,"*",$AddMin)))
Break
}
"FDR" {
$Temp = "T" + $Filter
Write-Verbose -Message "Removing '\FDR' files." -Verbose:$Verbose
Invoke-Command -Session $Sessions -ScriptBlock ([Scriptblock]::Create(($Command -f $SBLSrvrPath,"BIN",$Temp,"fdr",$AddMin)))
Break
}
"Crash" {
$Temp = "crash_" + $Filter
Write-Verbose -Message "Removing '\Crash' files." -Verbose:$Verbose
Invoke-Command -Session $Sessions -ScriptBlock ([Scriptblock]::Create(($Command -f $SBLSrvrPath,"BIN",$Temp,"txt",$AddMin)))
Break
}
"LOGARCHIVE" {
Write-Verbose -Message "Removing '\LOGARCHIVE' files." -Verbose:$Verbose
Invoke-Command -Session $Sessions -ScriptBlock ([Scriptblock]::Create(($Command1 -f $SBLSrvrPath,"LOGARCHIVE",$Filter,"log",$AddMin)))
Invoke-Command -Session $Sessions -ScriptBlock ([Scriptblock]::Create(($Command1 -f $SBLSrvrPath,"LOGARCHIVE",$Filter,"dmp",$AddMin)))
Break;
}
"DRCache" {
$Temp = "*cache"
Write-Verbose -Message "Removing '\DRCache' files." -Verbose:$Verbose
Invoke-Command -Session $Sessions -ScriptBlock ([Scriptblock]::Create(($Command -f $SBLSrvrPath,"BIN",$Temp,"dat",$AddMin)))
Break;
}
}
}
Remove-PSSession $Sessions
}
##change evtloglvl event_alias_name=level for component component_alias_name
##change evtloglvl event_alias_name=level for server siebel_server_name component component_alias_name
##list evtloglvl for component component_alias_name
## File Analyzer (LFA)
## Export ##
##Export-ModuleMember -Variable 'SBLGtwyPath'
##Export-ModuleMember -Variable 'SBLSrvrPath'
##Export-ModuleMember -Variable 'SBLGtwyServer'
##Export-ModuleMember -Variable 'SBLTempPath'
Export-ModuleMember -Function 'Set-SBLEnv'
Export-ModuleMember -Function 'Invoke-SBLWFP'
## Siebel Services
Export-ModuleMember -Function 'Stop-SBLServer'
Export-ModuleMember -Function 'Start-SBLServer'
Export-ModuleMember -Function 'Get-SBLServer'
Export-ModuleMember -Function 'Remove-SBLService'
Export-ModuleMember -Function 'Add-SBLService'
## Backup Gateway
Export-ModuleMember -Function 'Backup-SBLGtwy'
Export-ModuleMember -Function 'Stop-SBLGtwyServer'
Export-ModuleMember -Function 'Start-SBLGtwyServer'
Export-ModuleMember -Function 'Get-SBLGtwyServer'
## Siebel Server Components
Export-ModuleMember -Function 'Set-SBLSrvrComp'
Export-ModuleMember -Function 'Get-SBLSrvrComp'
## Siebel Gateway Param
Export-ModuleMember -Function 'Set-SBLGtwyEnvParam'
Export-ModuleMember -Function 'Set-SBLGtwySubSysParam'
## Siebel Gateway Log Level
Export-ModuleMember -Function 'Set-SBLGtwyEvtLogLevel'
Export-ModuleMember -Function 'Get-SBLGtwyEvtLogLevel'
## Siebel Logs
Export-ModuleMember -Function 'Get-SBLSrvrLogs'
Export-ModuleMember -Function 'Remove-SBLSrvrLogs'