[PS] New-Item: Should -Name support multiple values?

Discussion in 'Scripting' started by Alex K. Angelopoulos [MVP], May 18, 2006.

  1. Looking at New-Item, it occurs to me a useful behavior would be
    changing -Name <String> to -Name <String[]>. It would be nice if it
    supported semi-globbing or sequences, but that's probably over-integration.
    I DO think that support for multiple specific names would provide worthwhile
    value-add with minimal increase in complexity. That way, we can do this:

    New-Item -Path C:\temp -Name file1,file2,file3,file4 -Type file
     
    Alex K. Angelopoulos [MVP], May 18, 2006
    #1
    1. Advertisements

  2. Does this not work for you?

    "Hi.txt","There.txt" | % { new-item -path c:\temp -name $_ -type File }
     
    Lee Holmes [MSFT], May 19, 2006
    #2
    1. Advertisements

  3. Yes, it does. I'm just looking at how this might be made to perform the task
    without needing to go to a pipelined statement.

     
    Alex K. Angelopoulos [MVP], May 19, 2006
    #3
  4. Agreed. Please file this as a suggestion on MS Connect.

    --
    Lee Holmes [MSFT]
    Windows PowerShell Development
    Microsoft Corporation
    This posting is provided "AS IS" with no warranties, and confers no rights.

     
    Lee Holmes [MSFT], May 19, 2006
    #4
  5. Actually, I won't be requesting this. The first usage for New-Item allows
    the following, which clearly works:
    New-Item -Path C:\temp\file4,C:\temp\file5,C:\temp\file6 -Type file

    That's good enough to meet the need.

     
    Alex K. Angelopoulos [MVP], May 19, 2006
    #5
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.