How to modify Powershell script to use 0 as current day

I would like to modify this Powershell script so if you enter the number 0, it will accept today's date.
If Enter is pressed, it should not move ahead until only a Number is entered for the amount of days back.

Thanks in advance.

[code]$userDays = Read-Host -Prompt "How many days ago is this report for (no input = today)"
If ($userDays -ne $null) {
      Try {
            $daysAgo = [Int32]$userDays
      } Catch {
            Write-Warning "'$($userDays)' is not a number; will use 1 day!"
            $daysAgo = 1
      }
} Else {
      $daysAgo = 1
}
###SETUP START###
#-------DO NOT MODIFY-------#
      #Yesterdays Date
            $date = ((Get-Date).AddDays((-1 * $daysAgo))).ToString("MMM/dd/yyyy")
###SETUP END###/code]
100questionsAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

oBdACommented:
Like taht, for example?
$maxDays = 365
Do {
	$userDays = Read-Host -Prompt "How many days ago is this report for (0 = today, max $($maxDays), X = exit)"
	$userDays = $userDays.Trim()
} Until (($userDays -eq 'X') -or (($userDays -match '\d+') -and ($maxDays -ge $userDays)))
If ($userDays -eq 'X') {
	Exit
}
$daysAgo = [Int32]$userDays
$daysAgo
###SETUP START###
#-------DO NOT MODIFY-------#
	#Yesterdays Date
		$date = ((Get-Date).AddDays((-1 * $daysAgo))).ToString("MMM'/'dd'/'yyyy")
###SETUP END###

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
100questionsAuthor Commented:
Perfect, thank you.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.