Get-FilesFileContent

Reads a whole remote file as text or as bytes.

Syntax

__AllParameterSets

Get-FilesFileContent [-Path] <string> [-AsByteStream] [-Connection <FilesConnection>]
 [-WorkspaceScope <long>] [-NoWorkspaceScope]

Description

Get-FilesFileContent downloads the file at -Path into memory with the engine's download, bound to one version of the file where its storage allows, and writes it as one string, decoded as UTF-8 (a UTF-8 byte order mark is dropped), or with -AsByteStream as one byte array. The web app's page and a file that changed during the download are refused rather than returned. Use Receive-FilesFile for a file too large to hold in memory, or to write it to a local file or stream.

Examples

Example 1: Read a small text file

$settings = Get-FilesFileContent -Path config/settings.json | ConvertFrom-Json

Reads and parses a JSON file.

Example 2: Read a file's bytes

[byte[]] $bytes = Get-FilesFileContent -Path images/logo.png -AsByteStream

Keeps the bytes as they are.

Parameters

-AsByteStream

Writes the file's bytes, as one byte array, instead of its text.

  • Type: System.Management.Automation.SwitchParameter
  • Parameter sets: (All)

-Connection

The connection to use, from Connect-FilesAccount. Defaults to the current runspace's default connection.

  • Type: FilesCom.PowerShell.FilesConnection
  • Parameter sets: (All)

-NoWorkspaceScope

Runs this command's requests in no workspace, even if the connection has one. The connection itself is unchanged.

  • Type: System.Management.Automation.SwitchParameter
  • Parameter sets: (All)

-Path

The remote file, used exactly as written.

  • Type: System.String
  • Parameter sets: (All) (required, position 0, pipeline input by property name)

-WorkspaceScope

Runs this command's requests in this workspace instead of the connection's, including workspace 0. The connection itself is unchanged.

  • Type: System.Int64
  • Parameter sets: (All)

Common Parameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

Inputs

  • System.String: Remote paths, from the Path property of piped objects.

Outputs

  • System.String: The file's text.
  • System.Byte[]: With -AsByteStream, the file's bytes.

Notes

The whole file is held in memory. See about_FilesCom for connections, errors and previewing changes.

  • Get-Help about_FilesCom