PoshCode Archive  Artifact [68215937c0]

Artifact 68215937c063065320dc2ff263b2d24ae18ebda5afc15abb93766ff56b8d43e1:

  • File Get-Lotterynumbers.ps1 — part of check-in [2d970492f0] at 2018-06-10 12:59:03 on branch trunk — Generates lottery numbers based on user input. (user: unknown size: 1199)

# encoding: ascii
# api: powershell
# title: Get-Lotterynumbers
# description: Generates lottery numbers based on user input.
# version: 1.0
# type: script
# license: CC0
# x-poshcode-id: 1605
# x-archived: 2010-01-27T03:39:09
#
#
###########################################################################
#
# NAME: Get-Lotterynumbers.ps1
#
# AUTHOR: Jan Egil Ring
# EMAIL: jer@powershell.no
#
# COMMENT: Generates lottery numbers based on user input.
#
# You have a royalty-free right to use, modify, reproduce, and
# distribute this script file in any way you find useful, provided that
# you agree that the creator, owner above has no warranty, obligations,
# or liability for such use.
#
# VERSION HISTORY:
# 1.0 24.01.2010 - Initial release
#
###########################################################################

$maximumnumber = Read-Host "How many numbers are available in the lottery?"
$numbercount = Read-Host "How many numbers are drawn?"
$numbers = @()
do {
$number = Get-Random -Minimum 1 -Maximum $maximumnumber
if ($numbers -notcontains $number)
{
$numbers += $number
}
}
until ($numbers.count -eq $numbercount)
$numbers | Sort-Object