"Supply Values for the following parameters"

Welcome Forums General PowerShell Q&A "Supply Values for the following parameters"

Viewing 0 reply threads
  • Author
    • #5179
      Topics: 1562
      Replies: 0
      Points: 1
      Rank: Member

      by Cancerous at 2012-10-08 22:32:43

      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.

      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}
      I’ve tried running it as a function and just as a two line script, but it still produces the same result.


      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.


      by Klaas at 2012-10-09 00:45:45

      echo is an alias for write-output, and if you don’t tell it what it has to write, it will ask you.
      try Get-Help echo -full
      Maybe you want to use New-Item instead:
      if(test-path -path "C:\testran.flag") {New-Item -Type file -Path C:\users\admin\desktop\true.flag}

      by Cancerous at 2012-10-10 15:04:50

      Solved it using Add-Content

      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 ""}

Viewing 0 reply threads
  • The topic ‘"Supply Values for the following parameters"’ is closed to new replies.