Essentially want to have a document (random.txt) that will have a list of values in it. It will grab the random line, store it in a variable, display it, then remove it (by re-saving the document appears to be the best method I’ve found).
Random.txt
1
2
3
4
#--------------------------------------------------
$Number = Get-Random -InputObject (get-content C:\Scripts\random.txt)
$Number
# HERE IS WHERE I'M STUCK - the below doesn't work, but it's similar to what I've seen in places online, including this forum #
get-content "C:\Scripts\random.txt" | where { $_ -ne "$number" } | Out-File "C:\Scripts\random.txt"
#
Random.txt (New Values Left)
1
2
4
# ---------------------------------------
Rinse and repeat.
My method removes everything. I’ve tried permutations of it, and it doesn’t help.