Windows 7 Out-file problem

Discussion in 'Programming and Scripting' started by balubeto, Jun 24, 2012.

  1. balubeto

    balubeto Well-Known Member

    Joined:
    Apr 27, 2012
    Messages:
    53
    Likes Received:
    0
    Hi

    In the PowerShell 2.0 console in Windows 7 SP1, I wrote:

    Code:
    PS C:\Users\test\Documents\PowerShell> Get-Help * | Get-Help -Detailed | Out-File C:\Users\test\Documents\PowerShell\PowerShell_2,0_Guide.txt
    Out-File: Can not convert 'System.Object[]' to 'System.String' type required from 'FilePath' parameter. Specified method is not supported.
    In line:1 car:43
    + Get-Help * | Get-Help -Detailed | Out-File <<<<  C:\Users\test\Documents\PowerShell\PowerShell_2,0_Guide.txt
        + CategoryInfo          : InvalidArgument: (:) [Out-File], ParameterBindingException
        + FullyQualifiedErrorId : CannotConvertArgument,Microsoft.PowerShell.Commands.OutFileCommand
    PS C:\Users\test\Documents\PowerShell> Get-Help * | Get-Help -Detailed > C:\Users\test\Documents\PowerShell\PowerShell_2,0_Guide.txt
    Get-Help : Can not convert 'System.Object[]' to 'System.String' type required from 'Name' parameter. Specified method is not supported.
    In line:1 car:22
    + Get-Help * | Get-Help <<<<  -Detailed > C:\Users\test\Documents\PowerShell\PowerShell_2,0_Guide.txt
        + CategoryInfo          : InvalidArgument: (:) [Get-Help], ParameterBindingException
        + FullyQualifiedErrorId : CannotConvertArgument,Microsoft.PowerShell.Commands.GetHelpCommand
    PS C:\Users\test\Documents\PowerShell>
    
    Where I'm wrong?

    Thanks

    Bye
     
  2. debugthis

    debugthis New Member

    Joined:
    Jun 16, 2012
    Messages:
    4
    Likes Received:
    0
    Well, it's been 3 weeks, so this doesn't matter anyway. I'm CLUELESS of powershell, I don't use "seven" hardly at all, I'm Xp-based. Two things i'd try: put quotes around the outfile argument, and/or replace pipe with redir:
    C:\Users\test\Documents\PowerShell> Get-Help * | Get-Help -Detailed >"C:\Users\test\Documents\PowerShell\PowerShell_2,0_Guide.txt"
    or:
    C:\Users\test\Documents\PowerShell> Get-Help * | Get-Help -Detailed | Out-File "C:\Users\test\Documents\PowerShell\PowerShell_2,0_Guide.txt"

    Not knowing jiz about ps, this is all I can suggest. I have seven, but haven't used it.
     
  3. AceInfinity

    AceInfinity Senior Member
    Microsoft MVP

    Joined:
    Aug 12, 2011
    Messages:
    159
    Likes Received:
    11
    I'm a PowerShell guy :)

    First question, why are you piping the output of one help command to another?
    Code:
    Get-Help * | Get-Help -Detailed
    Another thing, don't use hardcoded paths, use environment locations:
    Code:
    "$env:UserProfile\Documents\PowerShell\PowerShell_2,0_Guide.txt"
    Here's what you want:
    Code:
    Get-Help * | Format-Table Name, Category, Synopsis | Out-File "$env:UserProfile\Documents\PowerShell\PowerShell_2,0_Guide.txt"
     

Share This Page

Loading...