-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebtrends.ps1
More file actions
204 lines (180 loc) · 4.71 KB
/
webtrends.ps1
File metadata and controls
204 lines (180 loc) · 4.71 KB
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
# $Id: webtrends.PS1,v 1.7 2009/10/31 15:17:34 powem Exp $
# Michael Powe
# 2008 Sep 2
# Last modified: $Date: 2009/10/31 15:17:34 $
# cmdlet functions to start and stop WebTrends services:
# UI, GeoTrends and Scheduler
# usage: Source this script. Then:
# Start-WebTrends geo -- start the GeoTrends server.
# Get-WebTrends -- get the status of the services.
function Start-WebTrends {
param([string]$svc=$(Throw "Specify 'ui', 'geo' or 'scheduler'"))
begin {
$wtsvc = Get-Service -DisplayName "*WebTrends*";
$wtui = $wtsvc | ?{$_.DisplayName -eq "WebTrends - User Interface"};
$wtgeo = $wtsvc | ?{$_.DisplayName -eq "WebTrends - GeoTrends Server"};
$wtsched = $wtsvc | ?{$_.DisplayName -eq "WebTrends - Scheduler Agent"};
}
process {
switch (($svc).toLower()){
"ui"
{
if ($wtui.Status -eq "Running"){
Write-Host "The UI service already is running.";
} else {
Write-Host "Starting the WebTrends UI server ...";
Start-Service wtui;
}
}
"geo"
{
if ($wtgeo.Status -eq "Running"){
Write-Host "The GeoTrends Server already is running.";
} else {
Write-Host "Starting GeoTrends Service...";
Start-Service $wtgeo.Name;
}
}
"scheduler"
{
if ($wtsched.Status -eq "Running"){
Write-Host "The scheduler already is running.";
} else {
Write-Host "Starting the scheduler ... ";
Start-Service $wtsched.Name;
}
}
} # end switch
}
end {
$wtui=$null;
$wtgeo=$null;
$wtsched=$null;
$wtsvc=$null;
}
} # end Start-WebTrends
function Stop-WebTrends {
param([string]$svc=$(Throw "specify 'ui', 'geo' or 'scheduler'"));
begin {
$wtsvc = Get-Service -DisplayName "*WebTrends*";
$wtui = $wtsvc | ?{$_.DisplayName -eq "WebTrends - User Interface"};
$wtgeo = $wtsvc | ?{$_.DisplayName -eq "WebTrends - GeoTrends Server"};
$wtsched = $wtsvc | ?{$_.DisplayName -eq "WebTrends - Scheduler Agent"};
}
process {
switch (($svc).toLower()){
"ui"
{
if ($wtui.Status -eq "Stopped"){
return "The UI service already is stopped.";
} else {
Write-Host "Stopping the UI services ...";
Stop-Service $wtui.Name;
}
}
"geo"
{
if ($wtgeo.Status -eq "Stopped"){
Write-Host "The GeoTrends Server already is stopped.";
} else {
Write-Host "Stopping GeoTrends Service...";
Stop-Service $wtgeo.Name;
}
}
"scheduler"
{
if ($wtsched.Status -eq "Stopped"){
Write-Host "The scheduler already is stopped.";
} else {
Write-Host "Stopping the scheduler ...";
Stop-Service $wtsched.Name;
}
}
} # end switch
}
end {
$wtui=$null;
$wtgeo=$null;
$wtsched=$null;
$wtsvc=$null;
}
} # end function Stop-WebTrends
function Restart-WebTrends {
param([string] $svc=$(Throw "specify 'ui', 'geo', or 'scheduler'"));
begin {
$wtsvc = Get-Service -DisplayName "*WebTrends*";
$wtui = $wtsvc | ?{$_.DisplayName -eq "WebTrends - User Interface"};
$wtgeo = $wtsvc | ?{$_.DisplayName -eq "WebTrends - GeoTrends Server"};
$wtsched = $wtsvc | ?{$_.DisplayName -eq "WebTrends - Scheduler Agent"};
[string]$wtSvcName = "";
Write-Host "Restarting ... ";
}
process {
switch (($svc).toLower()){
"ui"
{
$wtSvcName=$wtui.DisplayName;
if ($wtui.Status -eq "Stopped"){
Start-Service $wtui.Name;
Write-Host "Done.";
} else {
Stop-Service $wtui.Name;
Start-Sleep -Seconds 5;
Start-Service $wtui.Name;
}
}
"geo"
{
$wtSvcName=$wtgeo.DisplayName;
if ($wtgeo.Status -eq "Stopped"){
Start-Service $wtgeo.Name;
Write-Host "Done.";
} else {
Stop-Service $wtgeo.Name;
Start-Sleep -Seconds 5;
Start-Service $wtgeo.Name;
}
}
"scheduler"
{
$wtSvcName=$wtsched.DisplayName;
if ($wtsched.Status -eq "Stopped"){
Start-Service $wtsched.Name;
Write-Host "Done.";
} else {
Stop-Service $wtsched.Name;
Start-Sleep -Seconds 5;
Start-Service $wtsched.Name;
Write-Host "Done.";
}
}
} # end switch
}
end {
Write-Host "Service status is " (Get-Service -DisplayName $wtSvcName).Status;
$wtui=$null;
$wtgeo=$null;
$wtsched=$null;
$wtsvc=$null;
}
} # end function Restart-WebTrends
function Get-WebTrends {
begin {
$wtsvc = Get-Service -DisplayName "*WebTrends*" | Sort-Object -Property Status;
}
process {
$svcHeader = [string]::Format("{0,-40}", "Service");
$svcHeader += [string]::Format("{0,10}", "Status");
$l = '-' * 50;
Write-Host $svcHeader;
Write-Host $l;
foreach ($svc in $wtsvc){
$svcStr = [string]::Format("{0,-40}", $svc.DisplayName);
$svcStr += [string]::Format("{0,10}", $svc.Status);
Write-Host $svcStr;
}
}
end {
$wtsvc = $null;
}
} # end function Get-WebTrends