Windows Vista Forums

Prompt for input if import-csv not used?
  1. #1


    TC Guest

    Prompt for input if import-csv not used?

    Hi,

    I have a script that needs two parameters. I'd like to have it able to be
    fed these from a CSV using import-csv, or to prompt for them if import-csv is
    not used.



    Can anyone point me in the direction of some sample code that does this, or
    provide any other guidance?

    cheers,
    TC

      My System SpecsSystem Spec

  2. #2


    Kiron Guest

    RE: Prompt for input if import-csv not used?

    Try this:

    @'
    param ($text, $color)
    process {
    if ($_) {
    write-host $_.text -foreground $_.color -background 0
    } else {
    $text = read-host Text
    $color = read-host Color
    write-host $text -foreground $color -background 0
    }
    }
    '@ > scriptX.ps1

    @'
    Text,Color
    "Line 1",Blue
    "Line 2",Cyan
    "Line 3",Green
    "Line 4",Magenta
    "Line 5",Yellow
    '@ > data.csv

    ipcsv data.csv | .\scriptX

    ..\scriptX


    # delete test items
    ri scriptX.ps1, data.csv -vb

    --
    Kiron

      My System SpecsSystem Spec

Prompt for input if import-csv not used? problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
Change to C:\ Prompt from C:\Users\username> Prompt cyberbiker General Discussion 2 27 Nov 2009
No Video Input jlgrabner Media Center 1 25 Sep 2009
Input Command Nezmin2 General Discussion 2 25 Nov 2008
Scripting prompt input Please.... PowerShell 1 06 Aug 2008
Chinese Traditional Input using Phonetic Input Jess Vista General 0 11 Jan 2008