-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRun.ps1
59 lines (54 loc) · 1.61 KB
/
Run.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
Function MenuCreate {
#Creates a main menu that detects userID's existance and also displays it.
Write-Host "Pick An Option"
Write-Host "1: Select Random Subject"
Write-Host "2: Reset List"
Write-Host "Q: Please hit 'Q' to quit"
}
Function GetRandom {
$RunningArray = @()
$CSV = Import-Csv .\List.csv
For($idx = 0; $idx -lt $CSV.Count; $idx++) {
If($CSV[$idx].operations -lt 3){
$Temp = $CSV[$idx].Subject
$RunningArray += $Temp
Write-Host "DEBUG: $($CSV[$idx].Subject) was added"
}Else{
Write-Host "$($CSV[$idx].Subject) has been used too much." -Foregroundcolor Yellow
}
}
$Result = $RunningArray[$(Get-Random -Maximum $RunningArray.Count)]
Write-Host "Random Result: $Result" -Foregroundcolor Blue
For($ID = 0; $ID -lt $CSV.Count; $ID++){
If($Result -eq $Csv[$ID].Subject){
Write-Host "DEBUG: Result Equals Array"
$Temp = [int]$Csv[$ID].operations
$Temp++
$CSV[$ID].operations = $Temp
}
}
$Csv | Export-Csv .\List.csv
Pause
}
Function OperationReset {
$CSV = Import-Csv .\List.csv
For($idx = 0; $idx -lt $CSV.Count; $idx++) {
$Temp = $CSV[$idx].Operations
$Temp = 0
$Csv[$idx].operations = $Temp
}
$Csv | Export-Csv .\List.csv
}
While($true) {
Clear-Host
MenuCreate
$Selection = Read-Host "Please make a selection"
switch ($Selection) {
'1' { GetRandom }
'2' { OperationReset }
'q' {
write-Host 'Hope we could help!'
Return
}
}
}