bob
bob

Reputation: 993

Powershell: "Help Get-Content -Full" missing some parameters (raw, stream, encoding)

My question relates to a blog post at Hey Scripting Guy! by a member of the Windows PowerShell (Azure) team, June Blender.

"To get a JSON string from a JSON file, use the Get-Content cmdlet with its Raw parameter."

   PS C:\> Get-Content -Raw -Path .\myJson.json

"The Raw parameter tells Get-Content to ignore line breaks and return a single string."

Thinking this looks handy - I want to learn more about this parameter, I type the following commands and receive unexpected results:

    PS C:\> Update-Help
    PS C:\> Get-Help Get-Content -Parameter Raw
    Get-Help : No parameter matches criteria Raw. ##error etc.

    PS C:\> Get-Help Get-Content -Full | Out-String | Select-String 'Raw'
    PS C:\> 

In the ISE, intellisense offers 'raw' as a parameter of 'Get-Content' and in the normal shell tab-complete tells me it's a real parameter. I just can't seem to locate any documentation that explains it's usage. "Help Get-Content -Online" also returns nothing.

    PS C:\> Get-Command * -ParameterName 'raw'
    Cmdlet      Get-Content        Microsoft.PowerShell.Management

Get-Command confirms the parameter exists, is not a member of the 'Common Parameter' Set and is present in my version of PowerShell. My question:

Why are some parameters of "Get-Content" not visible in my help files or online but are still available for use, specifically -raw, -stream and -encoding. Is there a list of similarly hidden parameters for other Cmdlets?

I'm running PowerShell v4 on Windows 8.1 in a workgroup environment. Thanks for your help.

Update:

    $PSVersionTable
    PSVersion                      4.0
    WSManStackVersion              3.0
    SerializationVersion           1.1.0.1
    CLRVersion                     4.0.30319.34014
    BuildVersion                   6.3.9600.16394
    PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0}
    PSRemotingProtocolVersion      2.2
    
    $PSUICulture; $PSCulture
    en-GB
    en-NZ

Upvotes: 1

Views: 1871

Answers (3)

Adil Hindistan
Adil Hindistan

Reputation: 6605

I have the same version of PS / OS but an updated help file and get the following:

C:\> help get-content -param raw

-Raw <switch>
    Ignores newline characters and returns the entire contents of a file in one string. By default, the contents of a file is returned as a array of strings that is delimited by
    the newline character.

So, it looks like you just do not have the updated help files.

Make sure you are on an elevated PowerShell prompt (you started the PowerShell by right clicking on it and typing Run As Administrator) then run

update-help -verbose -force

If all that fails:

get-help get-content -online

http://technet.microsoft.com/library/hh847788(v=wps.630).aspx is where you need to look at for details of raw and you should be able to get to it by typing the following on the command line

I am assuming you have direct link to internet (no proxies etc involved)

Upvotes: 0

BartekB
BartekB

Reputation: 8650

That's common problem with dynamic parameters (and -Raw, -Encoding are examples of that). Any provider has ability to extend provider-related cmdlets with dynamic parameters. Still: I would expect it to work just fine if you are in correct provider.

Namely: if you are on c:\ drive, you should see help for Get-Content -Raw. Are you sure you didn't try it when you were in different provider (e.g. registry?)

For online help: instead of using cmdlet help, you need to read provider help. Online help for cmdlet has no way of guessing what provider you are in, so it can't support you with help for dynamic parameters.

Upvotes: 4

TomG
TomG

Reputation: 188

I have tried your commands in my Powershell (V4 on Windows 8.1). I get the expected results and there is no error:

PS C:\> get-help get-content -Parameter raw
-Raw <switch>
    Ignores newline characters and returns the entire contents of a file in on...

As the Parameter was introduced in PS3, are you running in compatibility mode like in an Exchange 2010 Shell? What shows the $PSVersionTable Variable?

Hope this helps

Upvotes: 1

Related Questions