Get-Content中的-raw开关参数在Powershell中到底有什么作用?查找有用的文档 [英] What does the -raw switch parameter in Get-Content really do in Powershell? Finding helpful documentation

查看:330
本文介绍了Get-Content中的-raw开关参数在Powershell中到底有什么作用?查找有用的文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试使用仅在JSON对象中接受原始文本或base64编码值的API.我要发布的内容是来自XML文件的数据.因此,我使用Powershell的Get-Content cmdlet(不带-Raw)从.xml中检索数据,然后进行base64编码并将其发送到API.然后,API对其进行解码,但是XML格式丢失了.

I've been trying to work with an API that only accepts raw text or base64 encoded values in a JSON object. The content I'm POSTing is data from an XML file. So I used Powershell's Get-Content cmdlet (without -Raw) to retrieve the data from the .xml and then base64 encode it and sent it to the API. The API then decodes it, but the XML formatting was lost.

我在Get-Content上找到了有关使用-Raw开关的SO帖子,但似乎此开关的文档含糊不清.当我使用-Raw开关,对其进行编码并将其发送回API时,格式是好的.

I found a SO post about using the -Raw switch on Get-Content, but it seems like the documentation for this switch is vague. When I used the -Raw switch, encoded it and sent it back to the API, the formatting was good.

推荐答案

按照您自己的,内置 MSDN文档应该是您的第一站.但是您已经有了RTFM!

As per Kory Gill's comment and your own, the built-in Get-Help and MSDN documentation should be your first port of call. But you've already RTFM!

如果失败, ss64 是Powershell文档和其他示例的很好参考.

When that fails, ss64 is great reference for Powershell documentation and additional examples.

此处获取内容页面.关于-Raw的说法是这样的:

Get-Content page here. It has this to say about -Raw:

将多行作为单个字符串返回(PowerShell 3.0)
在PowerShell 2.0中,使用静态方法:[System.IO.File] :: ReadAllText(string path)

Return multiple lines as a single string (PowerShell 3.0)
In PowerShell 2.0 use the static method: [System.IO.File]::ReadAllText(string path)

这篇关于Get-Content中的-raw开关参数在Powershell中到底有什么作用?查找有用的文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆