"dreeschkind" wrote:
> Why can't the new-item cmdlet just ask the user for the "value" argument if
> it needs it to create an item?
> I think it would be cool if cmdlets like this would also work
> 'interactively' without knowing all arguments/parameters in advance.
>
>
> PoSh 5 [137/] Function:\>new-item
>
> cmdlet new-item at command pipeline position 1
> Supply values for the following parameters:
> Path[0]: testf
> Path[1]:
> New-Item : Cannot process argument because the value of argument "value" is
> null.
> At line:1 char:8
> + new-item <<<<
I am not sure why you were getting that "value is null" error because when I
just pressed "enter" at "path[1]:", New-Item asked me for "type" of New item
to create like the following:
[^_^]PS[53]>New-Item
cmdlet New-Item at command pipeline position 1
Supply values for the following parameters:
Path[0]: testf
Path[1]:
Type: file
Directory: Microsoft.PowerShell.Core\FileSystem::C:\Program
Files\Windows PowerShell\v1.0
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 06/19/2006 오후 12:50 0 testf
[^_^]PS[54]>
>
> PoSh 6 [137/] Function:\>new-item -value {write-host "test"}
>
> cmdlet new-item at command pipeline position 1
> Supply values for the following parameters:
> Path[0]: testf
> Path[1]:
>
> CommandType Name
> Definition
> ----------- ----
> ----------
> Function testf
> write-host "test"
And the reason that "New-Item" doesn't ask for "value" is because,
PowerShell prompts user for an input only for mandatory parameters. If you
look at "new-item -?", "-Value" parameter's not required
-Value <System.Object>
The value the new item is to have.
Parameter required? false
So I think what you should be suggesting is, "-Value" parameter should be
mandator...

But I don't think that should be the case since, under file system provider,
one should be able to create a file or a directory any values...