Powershell - "Supply Values for the following parameters"


  1. Posts : 93
    Windows 7 Professional 32bit
       #1

    Powershell - "Supply Values for the following parameters"


    Noob to PS, but I know bash and batch.

    I'm trying to do a simple script that tests the existence of a file and then creates another depending on the outcome, but prompts me for a parameter value after running it.

    Code:
    Code:
    function test-existence {
    if(test-path -path "C:\testran.flag") {echo > C:\users\admin\desktop\true.flag}
    if(!(test-path -path "C:\testfailed.flag")) {echo > C:\users\admin\desktop\false.flag}
    test-existence
    I've tried running it as a function and just as a two line script, but it still produces the same result.

    Prompt:
    Supply values for the following parameters:
    InputObject[0]:
    This is part of a fully automated setup so I need this to run without any user interaction.


    Thanks.
      My Computer


  2. Posts : 6,285
    Windows 10 Pro X64
       #2

    Use Add-Content:
    Code:
    function test-existence 
      {
        if(test-path -path "C:\testran.flag") {Add-Content C:\users\admin\desktop\true.flag ""}
        if(!(test-path -path "C:\testfailed.flag")) {Add-Content C:\users\admin\desktop\false.flag ""}
      }
    test-existence
      My Computer


  3. Posts : 93
    Windows 7 Professional 32bit
    Thread Starter
       #3

    Thanks :)
      My Computer


  4. Posts : 6,285
    Windows 10 Pro X64
       #4

    You're welcome.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 22:07.
Find Us