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.
To type the key in an interactive session instead, read it with Read-Host -AsSecureString:
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
-SessionIdconnects with an existing session, also as aSecureString.-Credentialsigns in with a username and password, such as one fromGet-Credential, and creates a session the connection owns. Add-OneTimePasswordwith 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:
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:
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.