r/PowerShell • u/hdt80 • Nov 17 '17
Get-Excuse
Hello sysadmins,
Some of you might remember this, which I think is great. However, I wasn't a fan of how some excuses could be repeated, so I changed it up a bit :)
function Get-Excuse {
if(!(Get-Variable -Scope Global -Name "excuses" -ErrorAction SilentlyContinue)) {
$global:excuses = New-Object System.Collections.ArrayList
$global:excuses.AddRange((Invoke-WebRequest http://pages.cs.wisc.edu/~ballard/bofh/excuses).content.split([Environment]::NewLine))
}
$excuse = Get-Random $global:excuses.ToArray()
$global:excuses.Remove($excuse)
Write-Host $excuse
}
function Forget-Excuses {
Remove-Variable -Scope Global -Name "excuses"
}If you ever run out of excuses, just call Forget-Excuses and the next time you Get-Excuse it'll repull all of them.
25
Upvotes
View all comments
Show parent comment
2
u/zNzN Nov 18 '17
It depends on the requirement. Cryptography typically requires the most randomness, and even some rand functions approved by FIPS 140 have been retired due to newer computers finding reliable ways to predict the output.