Windows Vista Forums

Newbie : powershell file creation ...

  1. #1


    sko002 Guest

    Newbie : powershell file creation ...

    hi,
    I just installed powershell on my pc (which has the required configuration)
    but i can not even make simple task like file creation such as :

    PS W:\> "hello !" | Out-File c:\test.txt

    It returns this error below :

    Out-File : Unknown error "-1".
    At line:1 char:21
    + "hello !" | Out-File <<<< c:\test.txt

    I have searched for such topic on the web but nothing...
    Someone can help please ? Thanks.



      My System SpecsSystem Spec

  2. #2


    Klaus H. Probst Guest

    Re: Newbie : powershell file creation ...

    sko002 wrote:

    > hi,
    > I just installed powershell on my pc (which has the required configuration)
    > but i can not even make simple task like file creation such as :
    >
    > PS W:\> "hello !" | Out-File c:\test.txt
    Well really, this is no different than plain cmd.exe:

    WPS> "Hello" > c:\test.txt

    Simple, no? =)

    Also:

    WPS> get-help set-content

    --
    Klaus H. Probst
    http://www.simulplex.net/

      My System SpecsSystem Spec

  3. #3


    Jeff Guest

    Re: Newbie : powershell file creation ...

    On Oct 10, 1:07 pm, sko002 <sko...@xxxxxx> wrote:

    > hi,
    > I just installed powershell on my pc (which has the required configuration)
    > but i can not even make simple task like file creation such as :
    >
    > PS W:\> "hello !" | Out-File c:\test.txt
    >
    > It returns this error below :
    >
    > Out-File : Unknown error "-1".
    > At line:1 char:21
    > + "hello !" | Out-File <<<< c:\test.txt
    >
    > I have searched for such topic on the web but nothing...
    > Someone can help please ? Thanks.
    There isn't anything wrong with what you are trying to do. Is it
    possible you don't have the proper permissions to write to C:\? Try
    creating the file with redirection, and see if you get the same
    result:

    "hello !" > c:\test.txt

    Jeff


      My System SpecsSystem Spec

  4. #4


    sko002 Guest

    Re: Newbie : powershell file creation ...

    Hi Klaus,
    Sorry I may be unclear in my problem description.
    I wanted to use powershell for some tasks that cmd.exe can not do or do it
    easier at least !

    My problem is that powershell returns an error when I execute simple command
    like : "hello !" | Out-File c:\test.txt ...

    do you see what i mean ?!



    "Klaus H. Probst" wrote:

    > sko002 wrote:

    > > hi,
    > > I just installed powershell on my pc (which has the required configuration)
    > > but i can not even make simple task like file creation such as :
    > >
    > > PS W:\> "hello !" | Out-File c:\test.txt
    >
    > Well really, this is no different than plain cmd.exe:
    >
    > WPS> "Hello" > c:\test.txt
    >
    > Simple, no? =)
    >
    > Also:
    >
    > WPS> get-help set-content
    >
    > --
    > Klaus H. Probst
    > http://www.simulplex.net/
    >

      My System SpecsSystem Spec

  5. #5


    Kiron Guest

    Re: Newbie : powershell file creation ...

    Could you check the version installed, both outputs should be 1.0.0.0:

    (Get-Command Out-File).dll -replace '^.+((\d+\.){3}\d+).+$', '$1'
    "$((Get-Host).version)"

    --
    Kiron

      My System SpecsSystem Spec

  6. #6


    sko002 Guest

    Re: Newbie : powershell file creation ...

    Hi Jeff,

    I have admin permissions on my PC ...

    Same error with redirection :
    PS C:\> "hello !" > c:\test.txt
    Unknown error "-1".
    At line:1 char:12
    + "hello !" > <<<< c:\test.txt


    "Jeff" wrote:

    > On Oct 10, 1:07 pm, sko002 <sko...@xxxxxx> wrote:

    > > hi,
    > > I just installed powershell on my pc (which has the required configuration)
    > > but i can not even make simple task like file creation such as :
    > >
    > > PS W:\> "hello !" | Out-File c:\test.txt
    > >
    > > It returns this error below :
    > >
    > > Out-File : Unknown error "-1".
    > > At line:1 char:21
    > > + "hello !" | Out-File <<<< c:\test.txt
    > >
    > > I have searched for such topic on the web but nothing...
    > > Someone can help please ? Thanks.
    >
    > There isn't anything wrong with what you are trying to do. Is it
    > possible you don't have the proper permissions to write to C:\? Try
    > creating the file with redirection, and see if you get the same
    > result:
    >
    > "hello !" > c:\test.txt
    >
    > Jeff
    >
    >

      My System SpecsSystem Spec

  7. #7


    sko002 Guest

    Re: Newbie : powershell file creation ...

    Hi Kiron,
    Yes same version !

    PS W:\> (Get-Command Out-File).dll -replace '^.+((\d+\.){3}\d+).+$', '$1'
    1.0.0.0
    PS W:\> "$((Get-Host).version)"
    1.0.0.0



    "Kiron" wrote:

    > Could you check the version installed, both outputs should be 1.0.0.0:
    >
    > (Get-Command Out-File).dll -replace '^.+((\d+\.){3}\d+).+$', '$1'
    > "$((Get-Host).version)"
    >
    > --
    > Kiron
    >

      My System SpecsSystem Spec

  8. #8


    Kiron Guest

    Re: Newbie : powershell file creation ...

    Try this:

    powershell -noProfile {"hello !" | Out-File c:\test.txt}

    --
    Kiron

      My System SpecsSystem Spec

  9. #9


    sko002 Guest

    Re: Newbie : powershell file creation ...

    damn ! Still the same !!! : (

    PS W:\> powershell -noProfile {"hello !" | Out-File c:\test.txt}
    Out-File : Unknown error "-1".
    At line:1 char:21
    + "hello !" | Out-File <<<< c:\test.txt



    "Kiron" wrote:

    > Try this:
    >
    > powershell -noProfile {"hello !" | Out-File c:\test.txt}
    >
    > --
    > Kiron
    >

      My System SpecsSystem Spec

  10. #10


    Kiron Guest

    Re: Newbie : powershell file creation ...

    It is very odd sko002. I've never heard of 'unknown error "-1"'. You have the right version and you tried executing from a PowerShell session without user Profile... but the error persists. I can't think of any other suggestion than to either wait, there are very knowledgeable members on this group that can help; or unisntall PowerShell, download the version for your platform again and reinstall it.

    Sorry I couldn't help more.

    --
    Kiron

      My System SpecsSystem Spec

Page 1 of 4 123 ... LastLast

Newbie : powershell file creation ...
Similar Threads
Thread Forum
Powershell Newbie PowerShell
powershell newbie help PowerShell
Newbie to Powershell PowerShell
Newbie to PowerShell PowerShell
newbie - How to use FTP in powershell PowerShell