Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8813175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:46:47+00:00 2026-06-14T03:46:47+00:00

How do I put all of the below I have into one line so

  • 0

How do I put all of the below I have into one line so the user is able to enter at once?

So, instead of it popping up with a Read-Host every time they want to enter something in – it pops up once and states what you want to enter the date as..

So – “Please enter in FULL Date with time – ie 25 Oct 2012 9:00”

Also – if someone enters in a weird character, how do I let it error out?

$Day = $(Read-Host "Enter day of month")
if ($Day -eq ''){$Day = Get-Date -format dd}

$Month = $(Read-Host "Enter Month of Year")
if ($Month -eq ""){$Month = Get-Date -format MM}

$Year = $(Read-Host "Enter Year")
if ($Year -eq "") {$Year = Get-Date -format yy}

$Hour = $(Read-Host "Enter Hour")
if ($Hour -eq "") {$Hour = Get-Date -Format HH}

$Minute = $(Read-Host "Enter Minute")
if ($Minute -eq "") {$Minute = Get-Date -Format mm}

$Second = $(Read-Host "Enter Hour")
if ($Second -eq "") {$Second = Get-Date -Format ss}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T03:46:48+00:00Added an answer on June 14, 2026 at 3:46 am

    You can do something like this:

    do
    {
        $date= read-host "Please enter date & time (i.e.: '25/12/2012 09:00', '25 oct 2012 9:00'; date alone set time to 00:00):"
    
        $date = $date -as [datetime]
    
        if (!$date) {
            "Not A valid date and time"
        }
    } while ($date -isnot [datetime])
    
    $date
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I prefer to have one workspace and put all my projects into this one
Thank you all for helping. Below this post I put the corrected version's of
I want to put all my resources into a ClientBundle for easy management. So
So I need to put all the names in a file into column 1
With the code below I am able to open all text files in my
Hi I have an ajax script which validates the users information put into textboxes.
All of a sudden, I have run into an issue where I cannot step
Hi i have one editbox in that if user type the filtering should be
I put all my code in NS, similar to how jQuery is structured. I
I want to put all the requirements of a repoze Zope2 install in a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.