Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### Get number of "spins" for randomizing
- $spins = Read-Host "How many spins for randomizer?"
- ### Setup plain text file with comments for entry
- $rando = Get-Content $home\Desktop\rando\rando.txt
- ### Clean up the text file removing extra lines
- $rando2 = $rando |
- Select-String -Pattern ' Reply ' -NotMatch |
- Select-String -Pattern 'badge icon' -NotMatch
- $rando2 | Set-Content $home\Desktop\rando\rando2.txt -Force
- ### Create new text file only for people replying "In"
- $txtfile = "$home\Desktop\rando\rando3.txt"
- Set-Content -Path $txtfile -Value $null
- $content = $null
- $rando2 | ForEach-Object {
- If(($_ -Like "In*" -Or $_ -Like "So In*" ) -And ($_ -NotLike "NOT in*") ) {
- Add-Content -Path $txtfile -Value $content
- }
- $content = $_
- }
- ### Check for duplicates
- $rando3 = Get-Content $home\Desktop\rando\rando3.txt
- $dupes = $rando3 | sort | Group-Object | Where-Object { $_.Count -gt 1 } | Select -ExpandProperty Name
- If ($dupes.Count -gt 0) {
- Write-Host "Duplicate Entries Found. Please update rando3 file to continue."
- Write-Host $dupes
- Start-Sleep -Seconds 2
- Write-Host -NoNewLine 'Press any key to continue...'
- $null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')
- }
- ### Randomize list
- $winners = $rando3 |
- Sort-Object {Get-Random} |
- Sort-Object {Get-Random} |
- Sort-Object {Get-Random} |
- Sort-Object {Get-Random} |
- Sort-Object {Get-Random} |
- Sort-Object {Get-Random} |
- Sort-Object {Get-Random}
- ### Generate Winners
- $runtime = Get-Date
- $win_path = "$home\Desktop\rando\winners.txt"
- New-Item -Path $win_path -Value "List randomized at $runtime`r`r" -Force
- Add-Content -Path $win_path -Value "Winners:"
- Add-Content -Path $win_path -Value $winners[0..6]
- Add-Content -Path $win_path -Value "`r`rBackups:"
- Add-Content -Path $win_path -Value $winners[7..10]
- Get-Content $win_path
Advertisement
Add Comment
Please, Sign In to add comment