Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Should New-Item consistently create needed path elements?

Reply
 
Old 05-25-2006   #1 (permalink)
Alex K. Angelopoulos [MVP]


 
 

Should New-Item consistently create needed path elements?

New-Item is inconsistent in whether it will create necessary parent
containers if some containers in a path do not exist.

For example, suppose there is no FSO folder on drive C. Trying to create a
file within C:\FSO fails, but trying to create a directory within C:\FSO
succeeds - the parent and the child folders are both created.

With the registry provider, path elements must be created one by one; even
if there was a reason for the filesystem behavior, I would expect registry
key creation (which is directly analogous to filesystem directory creation)
would work.

Bug this, or is there a reason for the different behavior across providers
and itemtypes?



My System SpecsSystem Spec
Old 05-25-2006   #2 (permalink)
Jean


 
 

Re: Should New-Item consistently create needed path elements?

> With the registry provider, path elements must be created one by one

Just to say that you can do that in one line with "-force" parameter.

I note now that "-force" switch seems to work for HKLM only if the
first path element already exists (here SOFTWARE):

new-item "hklm:\SOFTWARE\testreg\test1\test2\" -force

and always works for HKCU :

new-item "hkcu:\TEST\testreg\test1\test2\" -force


The need sounds like the "-recurse" parameter of "remove-item" for me.

Regards,

--
Jean - JMST
Belgium


My System SpecsSystem Spec
Old 05-26-2006   #3 (permalink)
dreeschkind


 
 

RE: Should New-Item consistently create needed path elements?

I'd say bug it!
(still hating inconsistency...)

--
greetings
dreeschkind

"Alex K. Angelopoulos [MVP]" wrote:

> New-Item is inconsistent in whether it will create necessary parent
> containers if some containers in a path do not exist.
>
> For example, suppose there is no FSO folder on drive C. Trying to create a
> file within C:\FSO fails, but trying to create a directory within C:\FSO
> succeeds - the parent and the child folders are both created.
>
> With the registry provider, path elements must be created one by one; even
> if there was a reason for the filesystem behavior, I would expect registry
> key creation (which is directly analogous to filesystem directory creation)
> would work.
>
> Bug this, or is there a reason for the different behavior across providers
> and itemtypes?
>
>
>

My System SpecsSystem Spec
Old 06-04-2006   #4 (permalink)
Alex K. Angelopoulos [MVP]


 
 

Re: Should New-Item consistently create needed path elements?

Bugged here. I added a comment about possibly controlling this with
a -Recurse parameter.

https://connect.microsoft.com/feedba...5314&SiteID=99

"dreeschkind" <dreeschkind@discussions.microsoft.com> wrote in message
news:C1FB5829-B6DD-497C-A0F3-D825A7C339AC@microsoft.com...
> I'd say bug it!
> (still hating inconsistency...)
>
> --
> greetings
> dreeschkind
>
> "Alex K. Angelopoulos [MVP]" wrote:
>
>> New-Item is inconsistent in whether it will create necessary parent
>> containers if some containers in a path do not exist.
>>
>> For example, suppose there is no FSO folder on drive C. Trying to create
>> a
>> file within C:\FSO fails, but trying to create a directory within C:\FSO
>> succeeds - the parent and the child folders are both created.
>>
>> With the registry provider, path elements must be created one by one;
>> even
>> if there was a reason for the filesystem behavior, I would expect
>> registry
>> key creation (which is directly analogous to filesystem directory
>> creation)
>> would work.
>>
>> Bug this, or is there a reason for the different behavior across
>> providers
>> and itemtypes?
>>
>>
>>



My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Create Directory on a UNC Path PowerShell
path to item returned from get-childitem PowerShell
It it possible create an Game Explorer item myself? Vista Games
Vista Explorer Create New Item Not Visible on Create - Bug or Feature??? Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

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 34 35 36 37 38 39 40 41 42 43 44 45 46