> 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/set-pmpcconnection.md). Agents can also search and read this documentation through its [MCP server](https://docs.patchmypc.com/~gitbook/mcp).

# Set-PmpcConnection

Selects the Intune connection that deployment commands act on.

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

## Synopsis

Selects the Intune connection that deployment commands act on.

## Syntax

### Name (Default)

{% code collapsedlinecount="10" %}

```powershell
Set-PmpcConnection [-Name] <String> [-PassThru] [-WhatIf] [-Confirm] [<CommonParameters>]
```

{% endcode %}

### ConnectionId

{% code collapsedlinecount="10" %}

```powershell
Set-PmpcConnection -ConnectionId <Guid> [-PassThru] [-WhatIf] [-Confirm]
  [<CommonParameters>]
```

{% endcode %}

### InputObject

{% code collapsedlinecount="10" %}

```powershell
Set-PmpcConnection [-InputObject] <ConnectionDto> [-PassThru] [-WhatIf] [-Confirm]
  [<CommonParameters>]
```

{% endcode %}

## Description

Sets the connection context for the session. Every deployment command afterwards is scoped to it, and the SDK applies it automatically to creation and edit requests.

The connection can be given by object, by display name, or by ID. Name and ID are resolved against the live list first.

## Parameters

### -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                                             |

### -ConnectionId

ID of an Intune connection, as returned by Get-PmpcConnection.

| Attribute      | Value         |
| -------------- | ------------- |
| Type           | `System.Guid` |
| Required       | True          |
| Position       | Named         |
| Pipeline input | False         |
| Aliases        | None          |
| Parameter sets | ConnectionId  |

### -InputObject

The connection to select, as returned by Get-PmpcConnection.

| Attribute      | Value           |
| -------------- | --------------- |
| Type           | `ConnectionDto` |
| Required       | True            |
| Position       | 0               |
| Pipeline input | True (ByValue)  |
| Aliases        | None            |
| Parameter sets | InputObject     |

### -Name

Display name of the connection to select. Wildcards are accepted; an exact match wins over a wildcard match.

| Attribute      | Value           |
| -------------- | --------------- |
| Type           | `System.String` |
| Required       | True            |
| Position       | 0               |
| Pipeline input | False           |
| Aliases        | None            |
| Parameter sets | Name            |

### -PassThru

Return the object the cmdlet acted on. Without it the cmdlet writes nothing to the pipeline.

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

### -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

### ConnectionDto

A connection object, as returned by Get-PmpcConnection.

## Outputs

### ConnectionDto

Returned only with -PassThru.

## Examples

### Example 1: Select a connection by name

{% code collapsedlinecount="10" %}

```powershell
Set-PmpcConnection -Name 'Contoso Intune'
```

{% endcode %}

Resolves the name against the available connections and selects the match.

### Example 2: Select a connection from the pipeline

{% code collapsedlinecount="10" %}

```powershell
Get-PmpcConnection | Where-Object Type -eq 'Intune' | Set-PmpcConnection -PassThru
```

{% endcode %}

Selects the connection object directly and emits what was selected.

## Notes

Selecting a connection does not change the selected company, but the connection list comes from the selected company, so a company must be selected first.

## Related links

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

## See also

* SDK method: [SetSelectedConnectionAsync](https://docs.patchmypc.com/patch-my-pc-cloud-api/sdk/customer-and-connections.md#setselectedconnectionasync)
* SDK method: [GetAvailableConnectionsAsync](https://docs.patchmypc.com/patch-my-pc-cloud-api/sdk/customer-and-connections.md#getavailableconnectionsasync)
* REST operation: [`GET /v1/api/connections`](https://docs.patchmypc.com/patch-my-pc-cloud-api/rest-api/applications.md#get-available-connections)
* [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/set-pmpcconnection.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.
