locked
Creating a file with the cmdlet New-Item fails every time RRS feed

  • Question

  • <g class="gr_ gr_5 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar multiReplace" data-gr-id="5" id="5">I'm try</g> to create a file on my D: drive.  Here <g class="gr_ gr_4 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar multiReplace" data-gr-id="4" id="4">is</g> the results of my attempts:

    S C:\Users\droach> New-Item -Path 'D:Test\Doug\2020-03-20.ITMLog.10:31:04.log' -ItemType File
    ew-Item : The given path's format is not supported.
    t line:1 char:1
     New-Item -Path 'D:Test\Doug\2020-03-20.ITMLog.10:31:04.log' -ItemType File
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       + CategoryInfo          : NotSpecified: (:) [New-Item], NotSupportedException
       + FullyQualifiedErrorId : System.NotSupportedException,Microsoft.PowerShell.Commands.NewItemCo
      mmand
    S C:\Users\droach> D:
    S D:\> New-Item -Path '\Test\Doug\2020-03-20.ITMLog.10:31:04.log' -ItemType File
    ew-Item : Cannot find drive. A drive with the name '\Test\Doug\2020-03-20.ITMLog.10' does not
    xist.
    t line:1 char:1
     New-Item -Path '\Test\Doug\2020-03-20.ITMLog.10:31:04.log' -ItemType File
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       + CategoryInfo          : ObjectNotFound: (\Test\Doug\2020-03-20.ITMLog.10:String) [New-Item],
       DriveNotFoundException
       + FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.NewItemCommand
    S D:\> New-Item -Path '\\Test\Doug\2020-03-20.ITMLog.10:31:04.log' -ItemType File
    ew-Item : The given path's format is not supported.
    t line:1 char:1
     New-Item -Path '\\Test\Doug\2020-03-20.ITMLog.10:31:04.log' -ItemType File
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       + CategoryInfo          : NotSpecified: (:) [New-Item], NotSupportedException
       + FullyQualifiedErrorId : System.NotSupportedException,Microsoft.PowerShell.Commands.NewItemCo
      mmand

    S D:\> New-Item -Path 'Test\Doug\2020-03-20.ITMLog.10:31:04.log' -ItemType File
    ew-Item : Cannot find drive. A drive with the name 'Test\Doug\2020-03-20.ITMLog.10' does not
    xist.
    t line:1 char:1
     New-Item -Path 'Test\Doug\2020-03-20.ITMLog.10:31:04.log' -ItemType File
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       + CategoryInfo          : ObjectNotFound: (Test\Doug\2020-03-20.ITMLog.10:String) [New-Item],
      DriveNotFoundException
       + FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.NewItemCommand

    Can someone help as I want to use this function in a script for a project I'm working <g class="gr_ gr_155 gr-alert gr_gramm gr_inline_cards gr_run_anim Punctuation multiReplace" data-gr-id="155" id="155">on.</g>

    Friday, March 20, 2020 3:00 PM

Answers

  • Thanks I just realized it was the ":"
    • Marked as answer by jrv Tuesday, March 24, 2020 3:03 PM
    Friday, March 20, 2020 3:11 PM

All replies

  • You cannot use a ":" in a path.  That is exactly what the error message is telling you.

    "The given path's format is not supported."

    Take some time to learn how to read the error messages.  They usually point exactly at the error and many time tell you how to fix it.


    \_(ツ)_/


    • Edited by jrv Friday, March 20, 2020 3:04 PM
    Friday, March 20, 2020 3:04 PM
  • Aren't you just omitting the "\" after the "D:"???

       'D:\Test\Doug\2020-03-20.ITMLog.10:31:04.log'


    --- Rich Matheisen MCSE&I, Exchange Ex-MVP (16 years)

    Friday, March 20, 2020 3:05 PM
  • Please fix your post.  It has bad text in it.  One copy of an error message is all you need.

    On this site turn off Grammarly or update your Grammarly to the fixed version.


    \_(ツ)_/

    Friday, March 20, 2020 3:06 PM
  • Thanks I just realized it was the ":"
    • Marked as answer by jrv Tuesday, March 24, 2020 3:03 PM
    Friday, March 20, 2020 3:11 PM
  • Hi,

    Was your issue resolved?

    If you resolved it using our solution, please "mark it as answer" to help other community members find the helpful reply quickly.

    If you resolve it using your own solution, please share your experience and solution here. It will be very beneficial for other community members who have similar questions.

    If no, please reply and tell us the current situation in order to provide further help.

    Best Regards,

    Yang Yang
    Tuesday, March 24, 2020 2:40 AM
  • Aren't you just omitting the "\" after the "D:"???

       'D:\Test\Doug\2020-03-20.ITMLog.10:31:04.log'


    --- Rich Matheisen MCSE&I, Exchange Ex-MVP (16 years)

    The filename itself has colons in it too.
    • Edited by JS2010 Tuesday, March 24, 2020 3:01 PM
    Tuesday, March 24, 2020 2:44 PM