Skip to content

Adding Get-PnPPowerPlatformConnector #3487

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 125 additions & 0 deletions documentation/Get-PnPPowerPlatformConnectors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
---
Module Name: PnP.PowerShell
schema: 2.0.0
applicable: SharePoint Online
online version: https://pnp.github.io/powershell/cmdlets/Get-PnPPowerPlatformConnectors.html
external help file: PnP.PowerShell.dll-Help.xml
title: Get-PnPPowerPlatformConnectors
---

# Get-PnPPowerPlatformConnectors

## SYNOPSIS

**Required Permissions**

* Azure: management.azure.com

Returns the Custom Power Platform Connectors for a given environment

## SYNTAX

```powershell
Get-PnPPowerPlatformConnectors [-Environment <PowerPlatformEnvironmentPipeBind>] [-AsAdmin] [-Identity <PowerPlatformConnectorPipeBind>]
[-Connection <PnPConnection>] [-Verbose]
```

## DESCRIPTION
This cmdlet returns the custom connectors on a given enviroment.

## EXAMPLES

### Example 1
```powershell
$environment = Get-PnPPowerPlatformEnvironment
Get-PnPPowerPlatformConnectors -Environment $environment
```
This returns all the custom connectors for a given Power Platform environment

### Example 2
```powershell
$environment = Get-PnPPowerPlatformEnvironment
Get-PowerPlatformConnectorPipeBind -Environment $environment -Identity fba63225-baf9-4d76-86a1-1b42c917a182
```
This returns a specific custom connector

## PARAMETERS

### -Environment
The name of the Power Platform environment or an Environment object to retrieve the available custom connectors for.

```yaml
Type: PowerPlatformEnvironmentPipeBind
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: The default environment
Accept pipeline input: True
Accept wildcard characters: False
```

### -Identity
The Id of the connector to retrieve.

```yaml
Type: PowerPlatformConnectorPipeBind
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -AsAdmin
If specified returns all the custom connectors as admin. If not specified only the custom connectors for the current user will be returned.

```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -Connection
Optional connection to be used by the cmdlet.
Retrieve the value for this parameter by either specifying -ReturnConnection on Connect-PnPOnline or by executing Get-PnPConnection.

```yaml
Type: PnPConnection
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -Verbose
When provided, additional debug statements will be shown while executing the cmdlet.

```yaml
Type: SwitchParameter
Parameter Sets: (All)

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

## RELATED LINKS

[Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp)
90 changes: 90 additions & 0 deletions documentation/Get-PnPPowerPlatformSolution.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
---
Module Name: PnP.PowerShell
schema: 2.0.0
applicable: SharePoint Online
online version: https://pnp.github.io/powershell/cmdlets/Get-PnPPowerPlatformSolution.html
external help file: PnP.PowerShell.dll-Help.xml
title: Get-PnPPowerPlatformSolution
---

# Get-PnPPowerPlatformSolution

## SYNOPSIS

**Required Permissions**

* Azure: management.azure.com

Returns the Power Platform Solution/s for a given environment

## SYNTAX

```powershell
Get-PnPPowerPlatformSolution [-Environment <PowerPlatformEnvironmentPipeBind>] [-Name <PowerPlatformConnectorPipeBind>] [-Verbose]
```

## DESCRIPTION
This cmdlet returns the PowerPlatform solution on a given enviroment.

## EXAMPLES

### Example 1
```powershell
Get-PnPPowerPlatformSolution -Environment (Get-PnPPowerPlatformEnvironment)
```
This returns all the solutions for a given Power Platform environment

### Example 2
```powershell
Get-PnPPowerPlatformSolution -Environment (Get-PnPPowerPlatformEnvironment -IsDefault) -Name 'My Solution Name'
```
This returns a specific solution on the default Power Platform environment

## PARAMETERS

### -Environment
The name of the Power Platform environment or an Environment instance to retrieve the available solutions for. If omitted, the default environment will be used.

```yaml
Type: PowerPlatformEnvironmentPipeBind
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: The default environment
Accept pipeline input: True
Accept wildcard characters: False
```

### -Name
The Name of the solution to retrieve. If not provided, all the solutions will be returned.

```yaml
Type: PowerPlatformSolutionPipeBind
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Verbose
When provided, additional debug statements will be shown while executing the cmdlet.

```yaml
Type: SwitchParameter
Parameter Sets: (All)

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

## RELATED LINKS

[Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp)
26 changes: 26 additions & 0 deletions src/Commands/Base/PipeBinds/PowerPlatformSolutionPipeBind.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
namespace PnP.PowerShell.Commands.Base.PipeBinds
{
public sealed class PowerPlatformSolutionPipeBind
{
private readonly string _name;
private readonly Model.PowerPlatform.Environment.Solution.PowerPlatformSolution _solution;
public PowerPlatformSolutionPipeBind(string input)
{
_name = input;
}

public PowerPlatformSolutionPipeBind(Model.PowerPlatform.Environment.Solution.PowerPlatformSolution solution)
{
_solution = solution;
}

public string GetName()
{
if (_solution != null)
{
return _solution.FriendlyName;
}
return _name;
}
}
}
20 changes: 20 additions & 0 deletions src/Commands/Base/TokenHandling.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,26 @@ internal static string GetAccessToken(Cmdlet cmdlet, string appOnlyDefaultScope,
return null;
}

internal static string GetAccessTokenforPowerPlatformSolutions(Cmdlet cmdlet, PnPConnection connection,string enviormentBaseUrl)
{
var contextSettings = connection.Context.GetContextSettings();
var authManager = contextSettings.AuthenticationManager;
if (authManager != null)
{
if (contextSettings.Type == Framework.Utilities.Context.ClientContextType.SharePointACSAppOnly)
{
// When connected using ACS, we cannot get a token for another endpoint
throw new PSInvalidOperationException("Trying to get a token for a different endpoint while being connected through an ACS token is not possible. Please connect differently.");
}
string[] requiredScopes = new string[1] { enviormentBaseUrl + "/.default" };
cmdlet.WriteVerbose($"Acquiring oAuth token for {(requiredScopes.Length != 1 ? requiredScopes.Length + " " : "")}permission scope{(requiredScopes.Length != 1 ? "s" : "")} {string.Join(",", requiredScopes)}");
var accessToken = authManager.GetAccessTokenAsync(requiredScopes).GetAwaiter().GetResult();
cmdlet.WriteVerbose($"Access token acquired for PowerPlatformSolutions: {accessToken}");
return accessToken;
}
return null;
}

/// <summary>
/// Returns an access token based on a Managed Identity. Only works within Azure components supporting managed identities such as Azure Functions and Azure Runbooks.
/// </summary>
Expand Down
Loading