Solved Powershell - "Supply Values for the following parameters"

Cancerous

New member
Power User
Local time
1:14 AM
Messages
93
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 My Computer

At a glance

Windows 7 Professional 32bit
OS
Windows 7 Professional 32bit
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 My Computer

At a glance

Windows 10 Pro X64Intel Quad Core i7-4770 @ 3.4Ghz16.0GB PC3-12800 DDR3 SDRAM 1600 MHzIntel Integrated HD Graphics
Computer type
PC/Desktop
Computer Manufacturer/Model Number
Lenovo IdeaCenter 450
OS
Windows 10 Pro X64
CPU
Intel Quad Core i7-4770 @ 3.4Ghz
Memory
16.0GB PC3-12800 DDR3 SDRAM 1600 MHz
Graphics Card(s)
Intel Integrated HD Graphics
Sound Card
Realtek HD Audio
Monitor(s) Displays
HP 22" LCD
Screen Resolution
1680 x 1050
Hard Drives
250GB Samsung EVO SATA-3 SSD
2TB Seagate ST2000DM001 SATA-2
1.5TB Seagate ST3150041AS SATA
Keyboard
Dell USB
Mouse
Lenovo USB
Internet Speed
Cable via Road Runner 3MB Upload, 30MB Download
Antivirus
Windows Defender, MBAM Pro, MBAE
Browser
Seamonkey
Other Info
UEFI/GPT
PLDS DVD-RW DH16AERSH
Thanks :)
 

My Computer My Computer

At a glance

Windows 7 Professional 32bit
OS
Windows 7 Professional 32bit
You're welcome.
 

My Computer My Computer

At a glance

Windows 10 Pro X64Intel Quad Core i7-4770 @ 3.4Ghz16.0GB PC3-12800 DDR3 SDRAM 1600 MHzIntel Integrated HD Graphics
Computer type
PC/Desktop
Computer Manufacturer/Model Number
Lenovo IdeaCenter 450
OS
Windows 10 Pro X64
CPU
Intel Quad Core i7-4770 @ 3.4Ghz
Memory
16.0GB PC3-12800 DDR3 SDRAM 1600 MHz
Graphics Card(s)
Intel Integrated HD Graphics
Sound Card
Realtek HD Audio
Monitor(s) Displays
HP 22" LCD
Screen Resolution
1680 x 1050
Hard Drives
250GB Samsung EVO SATA-3 SSD
2TB Seagate ST2000DM001 SATA-2
1.5TB Seagate ST3150041AS SATA
Keyboard
Dell USB
Mouse
Lenovo USB
Internet Speed
Cable via Road Runner 3MB Upload, 30MB Download
Antivirus
Windows Defender, MBAM Pro, MBAE
Browser
Seamonkey
Other Info
UEFI/GPT
PLDS DVD-RW DH16AERSH
Back
Top