Authentication

Connect-FilesAccount connects to a Files.com site and makes the connection the default of the current PowerShell session, so the commands you run afterward use it without further arguments.

Connecting With an API Key

An API key is the usual credential for scripts. Connect-FilesAccount takes it as a SecureString, so keep it in a secret vault rather than in a script or on the command line.

Get-Secret requires Microsoft.PowerShell.SecretManagement, a registered vault, and an API key saved as FilesComApiKey.

$apiKey = Get-Secret -Name FilesComApiKey
Connect-FilesAccount -ApiKey $apiKey -BaseUrl https://mysite.files.com

To type the key in an interactive session instead, read it with Read-Host -AsSecureString:

$apiKey = Read-Host 'Files.com API key' -AsSecureString
Connect-FilesAccount -ApiKey $apiKey -BaseUrl https://mysite.files.com

The key's user determines what the commands can do. Create a key for the purpose, with the permissions the script needs.

Other Ways to Connect

  • -SessionId connects with an existing session, also as a SecureString.
  • -Credential signs in with a username and password, such as one from Get-Credential, and creates a session the connection owns. Add -OneTimePassword with the current two-factor authentication code when the user has one.

The Connect-FilesAccount reference, also shown by Get-Help Connect-FilesAccount -Full, describes every option, including the Workspace, proxy, retry and timeout settings.

Running a First Command

Once connected, list a folder to confirm the connection:

Get-FilesChildItem -Path reports/2026 | Where-Object Type -EQ file

The command writes each item of the folder, loading further pages only as the pipeline needs them.

Choosing a Connection

Every API command uses the current session's default connection unless you pass -Connection with another one from Connect-FilesAccount. To keep a second connection without replacing the default, connect it with -NoDefault and pass it explicitly. -WorkspaceScope runs one command's requests in a particular Workspace without changing the connection.

For a script that should leave the session default alone, use an explicit connection:

$connection = Connect-FilesAccount -ApiKey $apiKey -BaseUrl https://mysite.files.com -NoDefault
Get-FilesChildItem -Path reports -Connection $connection -WorkspaceScope 123 -ErrorAction Stop

Create a separate connection for each site. -WorkspaceId sets a connection's default Workspace; -WorkspaceScope selects one for a command. Neither selects another site nor grants access beyond the identity's permissions. Installed task scripts accepting -Connection can use a connection configured for that Workspace.