Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.



Windows 7: Powershell - "Supply Values for the following parameters"

08 Oct 2012   #1

Windows 7 Professional 32bit
 
 
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:
Quote:
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 System SpecsSystem Spec
.

09 Oct 2012   #2

Windows 8 Core X64
 
 

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 System SpecsSystem Spec
10 Oct 2012   #3

Windows 7 Professional 32bit
 
 

Thanks
My System SpecsSystem Spec
.


10 Oct 2012   #4

Windows 8 Core X64
 
 

You're welcome.
My System SpecsSystem Spec
Reply

 Powershell - "Supply Values for the following parameters"





Thread Tools




Our Sites

Site Links

About Us

Find 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 07:42 AM.
Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App
  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33