Windows Vista Forums

[Bug or not] Cmdlet Out-File
  1. #1


    A. Petitjean Guest

    [Bug or not] Cmdlet Out-File

    Hello !

    When I use Out-File to force to create a path when it does not exists, the
    command failed.
    Ex: Get-Process powershell | Out-File ./temp/toto.txt -force

    Out-File : Impossible de trouver une partie du chemin d'accès
    'D:\Users\Arnaud\Documents\@@PowerShell\scripts\temp\temp\toto.txt'.
    Au niveau de ligne : 1 Caractère : 34
    + Get-Process powershell | Out-File <<<< ./temp/toto.txt -force

    I have the rights to create files and directory on the destination.

    I have also noticed that the -whatif parameter has no effect on this cmdlet,
    is it normal ?

    Best regards from France,



    Arnaud PETITJEAN
    http://www.powershell-scripting.com
    The PowerShell's French Community

      My System SpecsSystem Spec

  2. #2


    Brandon Shell Guest

    Re: [Bug or not] Cmdlet Out-File

    I dont think its a bug, but maybe a missing feature
    -force <SwitchParameter>
    Overrides restrictions that prevent the command from succeeding, just so
    the changes do not compromise security. For example, Force will override the
    read-only attribute or create directories to complete a file path, but
    it will not attempt to change file permissions.



    "A. Petitjean" <APetitjean@discussions.microsoft.com> wrote in message
    news:C12EB5B4-87C6-4C0F-8BA9-1865B87AD7A9@microsoft.com...
    > Hello !
    >
    > When I use Out-File to force to create a path when it does not exists, the
    > command failed.
    > Ex: Get-Process powershell | Out-File ./temp/toto.txt -force
    >
    > Out-File : Impossible de trouver une partie du chemin d'accès
    > 'D:\Users\Arnaud\Documents\@@PowerShell\scripts\temp\temp\toto.txt'.
    > Au niveau de ligne : 1 Caractère : 34
    > + Get-Process powershell | Out-File <<<< ./temp/toto.txt -force
    >
    > I have the rights to create files and directory on the destination.
    >
    > I have also noticed that the -whatif parameter has no effect on this
    > cmdlet,
    > is it normal ?
    >
    > Best regards from France,
    >
    > Arnaud PETITJEAN
    > http://www.powershell-scripting.com
    > The PowerShell's French Community



      My System SpecsSystem Spec

  3. #3


    Keith Hill [MVP] Guest

    Re: [Bug or not] Cmdlet Out-File

    "A. Petitjean" <APetitjean@discussions.microsoft.com> wrote in message
    news:C12EB5B4-87C6-4C0F-8BA9-1865B87AD7A9@microsoft.com...
    > Hello !
    >
    > When I use Out-File to force to create a path when it does not exists, the
    > command failed.
    > Ex: Get-Process powershell | Out-File ./temp/toto.txt -force
    >


    Out-File will create a file that doesn't exist but it won't create
    intermediate directories. You would use:

    new-item -type directory (split-path -parent $TheFile)

    To create the necessary directories.

    --
    Keith


      My System SpecsSystem Spec

  4. #4


    A. Petitjean Guest

    Re: [Bug or not] Cmdlet Out-File

    I know that "Out-File will create a file that doesn't exist" and even without
    -force, but the help says, like brandon did, "...For example, Force will
    override the
    read-only attribute or create directories to complete a file path..."

    And what about the -whatif parameter ?

    Can you be more "verbose" ? ;-)

    Arnaud Petitjean

    "Keith Hill [MVP]" wrote:

    > "A. Petitjean" <APetitjean@discussions.microsoft.com> wrote in message
    > news:C12EB5B4-87C6-4C0F-8BA9-1865B87AD7A9@microsoft.com...
    > > Hello !
    > >
    > > When I use Out-File to force to create a path when it does not exists, the
    > > command failed.
    > > Ex: Get-Process powershell | Out-File ./temp/toto.txt -force
    > >

    >
    > Out-File will create a file that doesn't exist but it won't create
    > intermediate directories. You would use:
    >
    > new-item -type directory (split-path -parent $TheFile)
    >
    > To create the necessary directories.
    >
    > --
    > Keith
    >


      My System SpecsSystem Spec

  5. #5


    Keith Hill Guest

    Re: [Bug or not] Cmdlet Out-File

    "A. Petitjean" <APetitjean@discussions.microsoft.com> wrote in message
    news:27E8067A-8068-4556-801E-3C4F0E31A5F8@microsoft.com...
    >I know that "Out-File will create a file that doesn't exist" and even
    >without
    > -force, but the help says, like brandon did, "...For example, Force will
    > override the
    > read-only attribute or create directories to complete a file path..."
    >
    > And what about the -whatif parameter ?
    >
    > Can you be more "verbose" ? ;-)


    Oh sure, how about this? It is either a bug in the cmdlet or a bug in the
    docs. File a bug report on http://connect.microsoft.com site.

    --
    Keith


      My System SpecsSystem Spec

  6. #6


    A. Petitjean Guest

    Re: [Bug or not] Cmdlet Out-File

    Ok, bug repported on Microsoft Connect. Thanks


    Arnaud

    "Keith Hill" wrote:

    > "A. Petitjean" <APetitjean@discussions.microsoft.com> wrote in message
    > news:27E8067A-8068-4556-801E-3C4F0E31A5F8@microsoft.com...
    > >I know that "Out-File will create a file that doesn't exist" and even
    > >without
    > > -force, but the help says, like brandon did, "...For example, Force will
    > > override the
    > > read-only attribute or create directories to complete a file path..."
    > >
    > > And what about the -whatif parameter ?
    > >
    > > Can you be more "verbose" ? ;-)

    >
    > Oh sure, how about this? It is either a bug in the cmdlet or a bug in the
    > docs. File a bug report on http://connect.microsoft.com site.
    >
    > --
    > Keith
    >


      My System SpecsSystem Spec

  7. #7


    Keith Hill [MVP] Guest

    Re: [Bug or not] Cmdlet Out-File

    "A. Petitjean" <APetitjean@discussions.microsoft.com> wrote in message
    news:5F88BB49-9A4D-4D22-9B86-31949BE7C8C0@microsoft.com...
    > Ok, bug repported on Microsoft Connect. Thanks
    >


    Thanks! There are plenty of little issues like this (especially in the
    docs) that are good to get submitted so hopefully they get fixed in v.next.
    BTW, I also recommended perusing around some of the bugs/enhanement requests
    that have been submitted on the Connect site and voting for the ones you
    feel strongly about (either postitve or negative).

    --
    Keith


      My System SpecsSystem Spec

  8. #8


    Jacques Barathon [MS] Guest

    Re: [Bug or not] Cmdlet Out-File

    "A. Petitjean" <APetitjean@xxxxxx> wrote in message
    news:5F88BB49-9A4D-4D22-9B86-31949BE7C8C0@xxxxxx

    > Ok, bug repported on Microsoft Connect. Thanks
    Arnaud,

    Can you post the link to your Connect entry so that everyone who wants to
    vote for it can have a quick access to it?

    Thanks,
    Jacques


      My System SpecsSystem Spec

  9. #9


    A. Petitjean Guest

    Re: [Bug or not] Cmdlet Out-File

    Here's the precious link :
    https://connect.microsoft.com/feedba...5352&SiteID=99

    Best regards,

    Arnaud

    "Jacques Barathon [MS]" wrote:

    > "A. Petitjean" <APetitjean@xxxxxx> wrote in message
    > news:5F88BB49-9A4D-4D22-9B86-31949BE7C8C0@xxxxxx

    > > Ok, bug repported on Microsoft Connect. Thanks
    >
    > Arnaud,
    >
    > Can you post the link to your Connect entry so that everyone who wants to
    > vote for it can have a quick access to it?
    >
    > Thanks,
    > Jacques
    >
    >

      My System SpecsSystem Spec

  10. #10


    A. Petitjean Guest

    Re: [Bug or not] Cmdlet Out-File

    In browsing the bug repository it appears that the bug has already been
    submited, here :
    https://connect.microsoft.com/feedba...6833&SiteID=99

    "A. Petitjean" wrote:

    > Here's the precious link :
    > https://connect.microsoft.com/feedba...5352&SiteID=99
    >
    > Best regards,
    >
    > Arnaud
    >
    > "Jacques Barathon [MS]" wrote:
    >

    > > "A. Petitjean" <APetitjean@xxxxxx> wrote in message
    > > news:5F88BB49-9A4D-4D22-9B86-31949BE7C8C0@xxxxxx

    > > > Ok, bug repported on Microsoft Connect. Thanks
    > >
    > > Arnaud,
    > >
    > > Can you post the link to your Connect entry so that everyone who wants to
    > > vote for it can have a quick access to it?
    > >
    > > Thanks,
    > > Jacques
    > >
    > >

      My System SpecsSystem Spec

[Bug or not] Cmdlet Out-File problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
Quest AD cmdlet -what is the cmdlet to remove computer object IT Staff PowerShell 2 30 Oct 2008
Invoking Cmdlet Get-Location from cmdlet,cant get Currnt Directory Vikram PowerShell 2 05 Jun 2008
Clear-Content Cmdlet and Processing Lines in Text File Eudaimonia PowerShell 9 13 Dec 2007
can my cmdlet/snapin have a config file? Steve PowerShell 2 12 May 2007
'Write-object' is not recognized as a cmdlet, function, operable program, or script file PowershellBoy PowerShell 4 20 Oct 2006