> For the complete documentation index, see [llms.txt](https://docs.patchmypc.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.patchmypc.com/patch-my-pc-cloud-api/powershell/connect-pmpccloudwithpat.md). Agents can also search and read this documentation through its [MCP server](https://docs.patchmypc.com/~gitbook/mcp).

# Connect-PmpcCloudWithPat

Authenticates using a personal access token.

[Back to the Cloud Customer API overview](https://docs.patchmypc.com/patch-my-pc-cloud-api)

## Synopsis

Authenticates using a personal access token.

## Syntax

{% code collapsedlinecount="10" %}

```powershell
Connect-PmpcCloudWithPat [-Token] <SecureString> [-PassThru] [-Region <PmpcCloudRegion>]
  [-ConfigurationFile <String>] [-MaxSingleFileUploadSize <Int64>] [-WhatIf] [-Confirm]
  [<CommonParameters>]
```

{% endcode %}

## Description

Exchanges a personal access token (PAT) for a short-lived gateway token and scopes the session to the customer that token belongs to. Use this for scripts and other unattended callers. No company selection is needed afterwards, because the token identifies its own customer.

Production callers must provide the customer's region with -Region so the token exchange reaches the correct regional Patch My PC host.

## Parameters

### -ConfigurationFile

Path to a JSON configuration file supplying SDK settings, for callers that keep endpoints and keys in a file rather than passing them as arguments.

| Attribute      | Value           |
| -------------- | --------------- |
| Type           | `System.String` |
| Required       | False           |
| Position       | Named           |
| Pipeline input | False           |
| Aliases        | None            |

### -Confirm

Prompts you for confirmation before running the cmdlet.

| Attribute      | Value                                          |
| -------------- | ---------------------------------------------- |
| Type           | `System.Management.Automation.SwitchParameter` |
| Required       | False                                          |
| Position       | Named                                          |
| Pipeline input | False                                          |
| Aliases        | cf                                             |

### -MaxSingleFileUploadSize

Largest file uploaded in a single request before the SDK switches to a chunked upload.

| Attribute      | Value          |
| -------------- | -------------- |
| Type           | `System.Int64` |
| Required       | False          |
| Position       | Named          |
| Pipeline input | False          |
| Aliases        | None           |

### -PassThru

Emit the resolved company, which is otherwise not written to the pipeline.

| Attribute      | Value                                          |
| -------------- | ---------------------------------------------- |
| Type           | `System.Management.Automation.SwitchParameter` |
| Required       | False                                          |
| Position       | Named                                          |
| Pipeline input | False                                          |
| Aliases        | None                                           |

### -Region

Production region that owns the customer this token belongs to. Accepted values are Eu, Us, and Uk. Honoured by Release builds; maps to Patch My PC production regional hosts.

| Attribute       | Value             |
| --------------- | ----------------- |
| Type            | `PmpcCloudRegion` |
| Required        | False             |
| Position        | Named             |
| Pipeline input  | False             |
| Aliases         | None              |
| Accepted values | Eu, Us, Uk        |

### -Token

The personal access token created in the Patch My PC portal.

| Attribute      | Value                          |
| -------------- | ------------------------------ |
| Type           | `System.Security.SecureString` |
| Required       | True                           |
| Position       | 0                              |
| Pipeline input | False                          |
| Aliases        | None                           |

### -WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

| Attribute      | Value                                          |
| -------------- | ---------------------------------------------- |
| Type           | `System.Management.Automation.SwitchParameter` |
| Required       | False                                          |
| Position       | Named                                          |
| Pipeline input | False                                          |
| Aliases        | wi                                             |

### CommonParameters

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](https://go.microsoft.com/fwlink/?LinkID=113216).

## Inputs

### System.Security.SecureString

The personal access token.

## Outputs

### CompanyInfo

The customer the token belongs to. Emitted only with -PassThru.

## Examples

### Example 1: Authenticate from a stored token

{% code collapsedlinecount="10" %}

```powershell
$token = Read-Host -AsSecureString "PAT"
Connect-PmpcCloudWithPat -Token $token -Region Us
```

{% endcode %}

Prompts without echoing the token, then authenticates against the US production region.

### Example 2: Authenticate unattended and keep the company

{% code collapsedlinecount="10" %}

```powershell
$token = ConvertTo-SecureString $env:PMPC_PAT -AsPlainText -Force
$company = Connect-PmpcCloudWithPat -Token $token -Region Eu -PassThru
```

{% endcode %}

Reads the token from the environment, as a build agent would, and captures the resolved customer.

## Notes

Takes a SecureString so the token is not left in command history or a transcript. What the session can then do is bounded by the scopes the token was granted, so a call may be refused for lack of scope even though authentication succeeded. Manage personal access tokens from the Patch My PC portal.

-Region maps only to Patch My PC production regional hosts.

## Related links

* [Get-PmpcCloudSession](https://docs.patchmypc.com/patch-my-pc-cloud-api/powershell/get-pmpccloudsession.md)
* [PowerShell module](https://docs.patchmypc.com/patch-my-pc-cloud-api/powershell.md)

## See also

* SDK method: [AuthenticateWithPersonalAccessTokenAsync](https://docs.patchmypc.com/patch-my-pc-cloud-api/sdk/authentication.md#authenticatewithpersonalaccesstokenasync)
* REST operation: [`POST /v1/api/auth/token`](https://docs.patchmypc.com/patch-my-pc-cloud-api/rest-api/authentication.md#exchange-a-personal-access-token-for-an-access-token)
* [Cross-reference: cmdlets, SDK methods, and REST operations](https://docs.patchmypc.com/patch-my-pc-cloud-api/cross-reference.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.patchmypc.com/patch-my-pc-cloud-api/powershell/connect-pmpccloudwithpat.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
