locked
Need help creating a simple Script. RRS feed

  • Question

  • I just started powershell an need help in trying to make this script.

    Can anybody show me how?

    I know the very light basic.

     

    This is what the script needs to do.

    

     

    Prompt the user for a lename.

    

     

    Save today's date, followed by a list of the contents of the current directory in a le named <user's

    filename>.txt

     

    .

    For example, if the user answered

     

    myfile as the name, the lename to save under would be myfile.txt and

    have contents consisting of a line with the date, followed by as many lines as necessary to show the contents

    of the current directory.

    Tuesday, April 6, 2010 5:39 PM

Answers

  • Maybe?

    while ($filename -eq $null){

    $filename = read-host "Please enter a filename"

    }

    add-content $filename (get-date)

    add-content $filename (get-childitem)

    • Proposed as answer by Marco Shaw Wednesday, April 7, 2010 1:54 AM
    • Marked as answer by Marco Shaw Wednesday, April 7, 2010 3:39 PM
    Tuesday, April 6, 2010 5:52 PM