forked from MultiPoolMiner/MultiPoolMiner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Include.ps1
530 lines (427 loc) · 20.4 KB
/
Include.ps1
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
function Set-Stat {
param(
[Parameter(Mandatory = $true)]
[String]$Name,
[Parameter(Mandatory = $true)]
[Double]$Value,
[Parameter(Mandatory = $false)]
[DateTime]$Date = (Get-Date)
)
$Path = "Stats\$Name.txt"
$Date = $Date.ToUniversalTime()
$SmallestValue = 1E-20
$Stat = [PSCustomObject]@{
Live = $Value
Minute = $Value
Minute_Fluctuation = 1 / 2
Minute_5 = $Value
Minute_5_Fluctuation = 1 / 2
Minute_10 = $Value
Minute_10_Fluctuation = 1 / 2
Hour = $Value
Hour_Fluctuation = 1 / 2
Day = $Value
Day_Fluctuation = 1 / 2
Week = $Value
Week_Fluctuation = 1 / 2
Updated = $Date
}
if (Test-Path $Path) {$Stat = Get-Content $Path | ConvertFrom-Json}
$Stat = [PSCustomObject]@{
Live = [Double]$Stat.Live
Minute = [Double]$Stat.Minute
Minute_Fluctuation = [Double]$Stat.Minute_Fluctuation
Minute_5 = [Double]$Stat.Minute_5
Minute_5_Fluctuation = [Double]$Stat.Minute_5_Fluctuation
Minute_10 = [Double]$Stat.Minute_10
Minute_10_Fluctuation = [Double]$Stat.Minute_10_Fluctuation
Hour = [Double]$Stat.Hour
Hour_Fluctuation = [Double]$Stat.Hour_Fluctuation
Day = [Double]$Stat.Day
Day_Fluctuation = [Double]$Stat.Day_Fluctuation
Week = [Double]$Stat.Week
Week_Fluctuation = [Double]$Stat.Week_Fluctuation
Updated = [DateTime]$Stat.Updated
}
$Span_Minute = [Math]::Min(($Date - $Stat.Updated).TotalMinutes, 1)
$Span_Minute_5 = [Math]::Min((($Date - $Stat.Updated).TotalMinutes / 5), 1)
$Span_Minute_10 = [Math]::Min((($Date - $Stat.Updated).TotalMinutes / 10), 1)
$Span_Hour = [Math]::Min(($Date - $Stat.Updated).TotalHours, 1)
$Span_Day = [Math]::Min(($Date - $Stat.Updated).TotalDays, 1)
$Span_Week = [Math]::Min((($Date - $Stat.Updated).TotalDays / 7), 1)
$Stat = [PSCustomObject]@{
Live = $Value
Minute = ((1 - $Span_Minute) * $Stat.Minute) + ($Span_Minute * $Value)
Minute_Fluctuation = ((1 - $Span_Minute) * $Stat.Minute_Fluctuation) +
($Span_Minute * ([Math]::Abs($Value - $Stat.Minute) / [Math]::Max([Math]::Abs($Stat.Minute), $SmallestValue)))
Minute_5 = ((1 - $Span_Minute_5) * $Stat.Minute_5) + ($Span_Minute_5 * $Value)
Minute_5_Fluctuation = ((1 - $Span_Minute_5) * $Stat.Minute_5_Fluctuation) +
($Span_Minute_5 * ([Math]::Abs($Value - $Stat.Minute_5) / [Math]::Max([Math]::Abs($Stat.Minute_5), $SmallestValue)))
Minute_10 = ((1 - $Span_Minute_10) * $Stat.Minute_10) + ($Span_Minute_10 * $Value)
Minute_10_Fluctuation = ((1 - $Span_Minute_10) * $Stat.Minute_10_Fluctuation) +
($Span_Minute_10 * ([Math]::Abs($Value - $Stat.Minute_10) / [Math]::Max([Math]::Abs($Stat.Minute_10), $SmallestValue)))
Hour = ((1 - $Span_Hour) * $Stat.Hour) + ($Span_Hour * $Value)
Hour_Fluctuation = ((1 - $Span_Hour) * $Stat.Hour_Fluctuation) +
($Span_Hour * ([Math]::Abs($Value - $Stat.Hour) / [Math]::Max([Math]::Abs($Stat.Hour), $SmallestValue)))
Day = ((1 - $Span_Day) * $Stat.Day) + ($Span_Day * $Value)
Day_Fluctuation = ((1 - $Span_Day) * $Stat.Day_Fluctuation) +
($Span_Day * ([Math]::Abs($Value - $Stat.Day) / [Math]::Max([Math]::Abs($Stat.Day), $SmallestValue)))
Week = ((1 - $Span_Week) * $Stat.Week) + ($Span_Week * $Value)
Week_Fluctuation = ((1 - $Span_Week) * $Stat.Week_Fluctuation) +
($Span_Week * ([Math]::Abs($Value - $Stat.Week) / [Math]::Max([Math]::Abs($Stat.Week), $SmallestValue)))
Updated = $Date
}
if (-not (Test-Path "Stats")) {New-Item "Stats" -ItemType "directory"}
[PSCustomObject]@{
Live = [Decimal]$Stat.Live
Minute = [Decimal]$Stat.Minute
Minute_Fluctuation = [Double]$Stat.Minute_Fluctuation
Minute_5 = [Decimal]$Stat.Minute_5
Minute_5_Fluctuation = [Double]$Stat.Minute_5_Fluctuation
Minute_10 = [Decimal]$Stat.Minute_10
Minute_10_Fluctuation = [Double]$Stat.Minute_10_Fluctuation
Hour = [Decimal]$Stat.Hour
Hour_Fluctuation = [Double]$Stat.Hour_Fluctuation
Day = [Decimal]$Stat.Day
Day_Fluctuation = [Double]$Stat.Day_Fluctuation
Week = [Decimal]$Stat.Week
Week_Fluctuation = [Double]$Stat.Week_Fluctuation
Updated = [DateTime]$Stat.Updated
} | ConvertTo-Json | Set-Content $Path
$Stat
}
function Get-Stat {
param(
[Parameter(Mandatory = $true)]
[String]$Name
)
if (-not (Test-Path "Stats")) {New-Item "Stats" -ItemType "directory"}
Get-ChildItem "Stats" | Where-Object Extension -NE ".ps1" | Where-Object BaseName -EQ $Name | Get-Content | ConvertFrom-Json
}
function Get-ChildItemContent {
param(
[Parameter(Mandatory = $true)]
[String]$Path
)
$ChildItems = Get-ChildItem $Path | ForEach-Object {
$Name = $_.BaseName
$Content = @()
if ($_.Extension -eq ".ps1") {
$Content = &$_.FullName
}
else {
$Content = $_ | Get-Content | ConvertFrom-Json
}
$Content | ForEach-Object {
[PSCustomObject]@{Name = $Name; Content = $_}
}
}
$ChildItems | ForEach-Object {
$Item = $_
$ItemKeys = $Item.Content.PSObject.Properties.Name.Clone()
$ItemKeys | ForEach-Object {
if ($Item.Content.$_ -is [String]) {
$Item.Content.$_ = Invoke-Expression "`"$($Item.Content.$_)`""
}
elseif ($Item.Content.$_ -is [PSCustomObject]) {
$Property = $Item.Content.$_
$PropertyKeys = $Property.PSObject.Properties.Name
$PropertyKeys | ForEach-Object {
if ($Property.$_ -is [String]) {
$Property.$_ = Invoke-Expression "`"$($Property.$_)`""
}
}
}
}
}
$ChildItems
}
<#
function Set-Algorithm {
param(
[Parameter(Mandatory=$true)]
[String]$API,
[Parameter(Mandatory=$true)]
[Int]$Port,
[Parameter(Mandatory=$false)]
[Array]$Parameters = @()
)
$Server = "localhost"
switch($API)
{
"nicehash"
{
}
}
}
#>
function Get-HashRate {
param(
[Parameter(Mandatory = $true)]
[String]$API,
[Parameter(Mandatory = $true)]
[Int]$Port,
[Parameter(Mandatory = $false)]
[Object]$Parameters = @{},
[Parameter(Mandatory = $false)]
[Bool]$Safe = $false
)
$Server = "localhost"
$Multiplier = 1000
$Delta = 0.05
$Interval = 5
$HashRates = @()
$HashRates_Dual = @()
try {
switch ($API) {
"xgminer" {
$Message = @{command = "summary"; parameter = ""} | ConvertTo-Json -Compress
do {
$Client = New-Object System.Net.Sockets.TcpClient $server, $port
$Writer = New-Object System.IO.StreamWriter $Client.GetStream()
$Reader = New-Object System.IO.StreamReader $Client.GetStream()
$Writer.AutoFlush = $true
$Writer.WriteLine($Message)
$Request = $Reader.ReadLine()
$Data = $Request.Substring($Request.IndexOf("{"), $Request.LastIndexOf("}") - $Request.IndexOf("{") + 1) -replace " ", "_" | ConvertFrom-Json
$HashRate = if ($Data.SUMMARY.HS_5s -ne $null) {[Double]$Data.SUMMARY.HS_5s * [Math]::Pow($Multiplier, 0)}
elseif ($Data.SUMMARY.KHS_5s -ne $null) {[Double]$Data.SUMMARY.KHS_5s * [Math]::Pow($Multiplier, 1)}
elseif ($Data.SUMMARY.MHS_5s -ne $null) {[Double]$Data.SUMMARY.MHS_5s * [Math]::Pow($Multiplier, 2)}
elseif ($Data.SUMMARY.GHS_5s -ne $null) {[Double]$Data.SUMMARY.GHS_5s * [Math]::Pow($Multiplier, 3)}
elseif ($Data.SUMMARY.THS_5s -ne $null) {[Double]$Data.SUMMARY.THS_5s * [Math]::Pow($Multiplier, 4)}
elseif ($Data.SUMMARY.PHS_5s -ne $null) {[Double]$Data.SUMMARY.PHS_5s * [Math]::Pow($Multiplier, 5)}
if ($HashRate -ne $null) {
$HashRates += $HashRate
if (-not $Safe) {break}
}
$HashRate = if ($Data.SUMMARY.HS_av -ne $null) {[Double]$Data.SUMMARY.HS_av * [Math]::Pow($Multiplier, 0)}
elseif ($Data.SUMMARY.KHS_av -ne $null) {[Double]$Data.SUMMARY.KHS_av * [Math]::Pow($Multiplier, 1)}
elseif ($Data.SUMMARY.MHS_av -ne $null) {[Double]$Data.SUMMARY.MHS_av * [Math]::Pow($Multiplier, 2)}
elseif ($Data.SUMMARY.GHS_av -ne $null) {[Double]$Data.SUMMARY.GHS_av * [Math]::Pow($Multiplier, 3)}
elseif ($Data.SUMMARY.THS_av -ne $null) {[Double]$Data.SUMMARY.THS_av * [Math]::Pow($Multiplier, 4)}
elseif ($Data.SUMMARY.PHS_av -ne $null) {[Double]$Data.SUMMARY.PHS_av * [Math]::Pow($Multiplier, 5)}
if ($HashRate -eq $null) {$HashRates = @(); break}
$HashRates += $HashRate
if (-not $Safe) {break}
Start-Sleep $Interval
} while ($HashRates.Count -lt 6)
}
"ccminer" {
$Message = "summary"
do {
$Client = New-Object System.Net.Sockets.TcpClient $server, $port
$Writer = New-Object System.IO.StreamWriter $Client.GetStream()
$Reader = New-Object System.IO.StreamReader $Client.GetStream()
$Writer.AutoFlush = $true
$Writer.WriteLine($Message)
$Request = $Reader.ReadLine()
$Data = $Request -split ";" | ConvertFrom-StringData
$HashRate = if ([Double]$Data.KHS -ne 0 -or [Double]$Data.ACC -ne 0) {$Data.KHS}
if ($HashRate -eq $null) {$HashRates = @(); break}
$HashRates += [Double]$HashRate * $Multiplier
if (-not $Safe) {break}
Start-Sleep $Interval
} while ($HashRates.Count -lt 6)
}
"nicehashequihash" {
$Message = "status"
$Client = New-Object System.Net.Sockets.TcpClient $server, $port
$Writer = New-Object System.IO.StreamWriter $Client.GetStream()
$Reader = New-Object System.IO.StreamReader $Client.GetStream()
$Writer.AutoFlush = $true
do {
$Writer.WriteLine($Message)
$Request = $Reader.ReadLine()
$Data = $Request | ConvertFrom-Json
$HashRate = $Data.result.speed_hps
if ($HashRate -eq $null) {$HashRate = $Data.result.speed_sps}
if ($HashRate -eq $null) {$HashRates = @(); break}
$HashRates += [Double]$HashRate
if (-not $Safe) {break}
Start-Sleep $Interval
} while ($HashRates.Count -lt 6)
}
"nicehash" {
$Message = @{id = 1; method = "algorithm.list"; params = @()} | ConvertTo-Json -Compress
$Client = New-Object System.Net.Sockets.TcpClient $server, $port
$Writer = New-Object System.IO.StreamWriter $Client.GetStream()
$Reader = New-Object System.IO.StreamReader $Client.GetStream()
$Writer.AutoFlush = $true
do {
$Writer.WriteLine($Message)
$Request = $Reader.ReadLine()
$Data = $Request | ConvertFrom-Json
$HashRate = $Data.algorithms.workers.speed
if ($HashRate -eq $null) {$HashRates = @(); break}
$HashRates += [Double]($HashRate | Measure-Object -Sum).Sum
if (-not $Safe) {break}
Start-Sleep $Interval
} while ($HashRates.Count -lt 6)
}
"ewbf" {
$Message = @{id = 1; method = "getstat"} | ConvertTo-Json -Compress
$Client = New-Object System.Net.Sockets.TcpClient $server, $port
$Writer = New-Object System.IO.StreamWriter $Client.GetStream()
$Reader = New-Object System.IO.StreamReader $Client.GetStream()
$Writer.AutoFlush = $true
do {
$Writer.WriteLine($Message)
$Request = $Reader.ReadLine()
$Data = $Request | ConvertFrom-Json
$HashRate = $Data.result.speed_sps
if ($HashRate -eq $null) {$HashRates = @(); break}
$HashRates += [Double]($HashRate | Measure-Object -Sum).Sum
if (-not $Safe) {break}
Start-Sleep $Interval
} while ($HashRates.Count -lt 6)
}
"claymore" {
do {
$Request = Invoke-WebRequest "http://$($Server):$Port" -UseBasicParsing
$Data = $Request.Content.Substring($Request.Content.IndexOf("{"), $Request.Content.LastIndexOf("}") - $Request.Content.IndexOf("{") + 1) | ConvertFrom-Json
$HashRate = $Data.result[2].Split(";")[0]
$HashRate_Dual = $Data.result[4].Split(";")[0]
if ($HashRate -eq $null -or $HashRate_Dual -eq $null) {$HashRates = @(); $HashRate_Dual = @(); break}
if ($Request.Content.Contains("ETH:")) {$HashRates += [Double]$HashRate * $Multiplier; $HashRates_Dual += [Double]$HashRate_Dual * $Multiplier}
else {$HashRates += [Double]$HashRate; $HashRates_Dual += [Double]$HashRate_Dual}
if (-not $Safe) {break}
Start-Sleep $Interval
} while ($HashRates.Count -lt 6)
}
"fireice" {
do {
$Request = Invoke-WebRequest "http://$($Server):$Port/h" -UseBasicParsing
$Data = $Request.Content -split "</tr>" -match "total*" -split "<td>" -replace "<[^>]*>", ""
$HashRate = $Data[1]
if ($HashRate -eq "") {$HashRate = $Data[2]}
if ($HashRate -eq "") {$HashRate = $Data[3]}
if ($HashRate -eq $null) {$HashRates = @(); break}
$HashRates += [Double]$HashRate
if (-not $Safe) {break}
Start-Sleep $Interval
} while ($HashRates.Count -lt 6)
}
"wrapper" {
do {
$HashRate = Get-Content ".\Wrapper_$Port.txt"
if ($HashRate -eq $null) {Start-Sleep $Interval; $HashRate = Get-Content ".\Wrapper_$Port.txt"}
if ($HashRate -eq $null) {$HashRates = @(); break}
$HashRates += [Double]$HashRate
if (-not $Safe) {break}
Start-Sleep $Interval
} while ($HashRates.Count -lt 6)
}
}
$HashRates_Info = $HashRates | Measure-Object -Maximum -Minimum -Average
if ($HashRates_Info.Maximum - $HashRates_Info.Minimum -le $HashRates_Info.Average * $Delta) {$HashRates_Info.Maximum}
$HashRates_Info_Dual = $HashRates_Dual | Measure-Object -Maximum -Minimum -Average
if ($HashRates_Info_Dual.Maximum - $HashRates_Info_Dual.Minimum -le $HashRates_Info_Dual.Average * $Delta) {$HashRates_Info_Dual.Maximum}
}
catch {
}
}
filter ConvertTo-Hash {
$Hash = $_
switch ([math]::truncate([math]::log($Hash, [Math]::Pow(1000, 1)))) {
0 {"{0:n2} H" -f ($Hash / [Math]::Pow(1000, 0))}
1 {"{0:n2} KH" -f ($Hash / [Math]::Pow(1000, 1))}
2 {"{0:n2} MH" -f ($Hash / [Math]::Pow(1000, 2))}
3 {"{0:n2} GH" -f ($Hash / [Math]::Pow(1000, 3))}
4 {"{0:n2} TH" -f ($Hash / [Math]::Pow(1000, 4))}
Default {"{0:n2} PH" -f ($Hash / [Math]::Pow(1000, 5))}
}
}
function Get-Combination {
param(
[Parameter(Mandatory = $true)]
[Array]$Value,
[Parameter(Mandatory = $false)]
[Int]$SizeMax = $Value.Count,
[Parameter(Mandatory = $false)]
[Int]$SizeMin = 1
)
$Combination = [PSCustomObject]@{}
for ($i = 0; $i -lt $Value.Count; $i++) {
$Combination | Add-Member @{[Math]::Pow(2, $i) = $Value[$i]}
}
$Combination_Keys = $Combination | Get-Member -MemberType NoteProperty | Select-Object -ExpandProperty Name
for ($i = $SizeMin; $i -le $SizeMax; $i++) {
$x = [Math]::Pow(2, $i) - 1
while ($x -le [Math]::Pow(2, $Value.Count) - 1) {
[PSCustomObject]@{Combination = $Combination_Keys | Where-Object {$_ -band $x} | ForEach-Object {$Combination.$_}}
$smallest = ($x -band - $x)
$ripple = $x + $smallest
$new_smallest = ($ripple -band - $ripple)
$ones = (($new_smallest / $smallest) -shr 1) - 1
$x = $ripple -bor $ones
}
}
}
function Start-SubProcess {
param(
[Parameter(Mandatory = $true)]
[String]$FilePath,
[Parameter(Mandatory = $false)]
[String]$ArgumentList = "",
[Parameter(Mandatory = $false)]
[String]$WorkingDirectory = ""
)
$Job = Start-Job -ArgumentList $PID, $FilePath, $ArgumentList, $WorkingDirectory {
param($ControllerProcessID, $FilePath, $ArgumentList, $WorkingDirectory)
$ControllerProcess = Get-Process -Id $ControllerProcessID
if ($ControllerProcess -eq $null) {return}
$ProcessParam = @{}
$ProcessParam.Add("FilePath", $FilePath)
$ProcessParam.Add("WindowStyle", 'Minimized')
if ($ArgumentList -ne "") {$ProcessParam.Add("ArgumentList", $ArgumentList)}
if ($WorkingDirectory -ne "") {$ProcessParam.Add("WorkingDirectory", $WorkingDirectory)}
$Process = Start-Process @ProcessParam -PassThru
if ($Process -eq $null) {
[PSCustomObject]@{ProcessId = $null}
return
}
[PSCustomObject]@{ProcessId = $Process.Id; ProcessHandle = $Process.Handle}
$ControllerProcess.Handle | Out-Null
$Process.Handle | Out-Null
do {if ($ControllerProcess.WaitForExit(1000)) {$Process.CloseMainWindow() | Out-Null}}
while ($Process.HasExited -eq $false)
}
do {Start-Sleep 1; $JobOutput = Receive-Job $Job}
while ($JobOutput -eq $null)
$Process = Get-Process | Where-Object Id -EQ $JobOutput.ProcessId
$Process.Handle | Out-Null
$Process
}
function Expand-WebRequest {
param(
[Parameter(Mandatory = $true)]
[String]$Uri,
[Parameter(Mandatory = $true)]
[String]$Path
)
$FolderName_Old = ([IO.FileInfo](Split-Path $Uri -Leaf)).BaseName
$FolderName_New = Split-Path $Path -Leaf
$FileName = "$FolderName_New$(([IO.FileInfo](Split-Path $Uri -Leaf)).Extension)"
if (Test-Path $FileName) {Remove-Item $FileName}
if (Test-Path "$(Split-Path $Path)\$FolderName_New") {Remove-Item "$(Split-Path $Path)\$FolderName_New" -Recurse}
if (Test-Path "$(Split-Path $Path)\$FolderName_Old") {Remove-Item "$(Split-Path $Path)\$FolderName_Old" -Recurse}
Invoke-WebRequest $Uri -OutFile $FileName -UseBasicParsing
Start-Process "7z" "x $FileName -o$(Split-Path $Path)\$FolderName_Old -y -spe" -Wait
if (Get-ChildItem "$(Split-Path $Path)\$FolderName_Old" | Where-Object PSIsContainer -EQ $false) {
Rename-Item "$(Split-Path $Path)\$FolderName_Old" "$FolderName_New"
}
else {
Get-ChildItem "$(Split-Path $Path)\$FolderName_Old" | Where-Object PSIsContainer -EQ $true | ForEach-Object {Move-Item "$(Split-Path $Path)\$FolderName_Old\$_" "$(Split-Path $Path)\$FolderName_New"}
Remove-Item "$(Split-Path $Path)\$FolderName_Old"
}
}
function Get-Algorithm {
param(
[Parameter(Mandatory = $true)]
[String]$Algorithm
)
$Algorithms = Get-Content "Algorithms.txt" | ConvertFrom-Json
$Algorithm = (Get-Culture).TextInfo.ToTitleCase(($Algorithm -replace "-", " " -replace "_", " ")) -replace " "
if ($Algorithms.$Algorithm) {$Algorithms.$Algorithm}
else {$Algorithm}
}