Test-FilesPath

Tells whether a file or folder is at a remote path.

Syntax

__AllParameterSets

Test-FilesPath [-Path] <string> [-PathType <FilesPathType>] [-Connection <FilesConnection>]
 [-WorkspaceScope <long>] [-NoWorkspaceScope]

Description

Test-FilesPath returns $true when Files.com has a file or folder at -Path, and $false when it has nothing there, or, with -PathType, nothing of that kind. It changes nothing. Any other error, such as missing permission, fails the command rather than returning $false.

Examples

Example 1: Check for a file before downloading it

if (Test-FilesPath -Path reports/daily.csv -PathType File) {
    Receive-FilesFile -RemotePath reports/daily.csv -LiteralPath ./daily.csv
}

Downloads the report only if it exists.

Parameters

-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 path, used exactly as written.

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

-PathType

Whether to look for a file, a folder or either; by default either.

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

-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.Boolean: Whether something of the kind asked for is at the path.

Notes

Any checks for a file first and then, if there is none, for a folder: two requests when nothing is there. See about_FilesCom for connections, errors and previewing changes.

  • Get-Help about_FilesCom