Skip to content

Commit 0b3bdd0

Browse files
Fixed Get-PnPFlow not working without -AsAdmin (#4244)
* Fixing Get-PnPFlow not working without -AsAdmin * Added PR reference --------- Co-authored-by: Gautam Sheth <[email protected]>
1 parent 6f8fa98 commit 0b3bdd0

File tree

4 files changed

+6
-4
lines changed

4 files changed

+6
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
3636
- Fix issue with Power Platform cmdlets not working correctly in non-commercial cloud environments.
3737
- Fix issue with `Get-PnPFlow` not working correctly when `-AsAdmin` parameter is specified due to API changes.
3838
- Fix `Connect-PnPOnline` not returning correct `ClientId` in the connection object.
39-
39+
- Fixed `Get-PnPFlow` not working without `-AsAdmin` [#4244](https://github.com/pnp/powershell/pull/4244)
4040
### Removed
4141

4242
### Contributors

src/Commands/Base/PnPConnectedCmdlet.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ protected override void ProcessRecord()
6363
switch (ex)
6464
{
6565
case Model.Graph.GraphException gex:
66-
errorMessage = $"{gex.HttpResponse.ReasonPhrase} ({(int)gex.HttpResponse.StatusCode}): {gex.Error.Message}";
66+
errorMessage = $"{gex.HttpResponse.ReasonPhrase} ({(int)gex.HttpResponse.StatusCode}): {(gex.Error != null ? gex.Error.Message : gex.HttpResponse.Content.ReadAsStringAsync().Result)}";
6767
break;
6868

6969
case Core.SharePointRestServiceException rex:

src/Commands/Base/TokenHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ internal static string GetAccessToken(Cmdlet cmdlet, string audience, PnPConnect
193193
}
194194
if (!permissionsInPlace)
195195
{
196-
cmdlet.WriteVerbose($"The currect access token might not have the required permissions to execute this cmdlet. Required are one or more of the following: {string.Join(", ", permissionEvaluations.Select(p => p.MissingPermissions))}");
196+
cmdlet.WriteVerbose($"The currect access token might not have the required permissions to execute this cmdlet. Required are one or more of the following: {string.Join(", ", permissionEvaluations.Select(p => string.Join(", ", p.MissingPermissions)))}");
197197
}
198198

199199
return accessToken;

src/Commands/PowerPlatform/PowerAutomate/GetFlow.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ protected override void ExecuteCmdlet()
8181

8282
WriteVerbose($"Retrieving all Power Automate Flows within environment '{environmentName}'{(filter != null ? $" with filter '{filter}'" : "")}");
8383

84-
var flows = GraphHelper.GetResultCollection<Model.PowerPlatform.PowerAutomate.Flow>(this, Connection, baseUrl + $"/providers/Microsoft.ProcessSimple{(AsAdmin ? "/scopes/admin" : "")}/environments/{environmentName}/v2/flows?api-version=2016-11-01{(filter != null ? $"&$filter={filter}" : "")}", AccessToken);
84+
var flowUrl = $"{baseUrl}/providers/Microsoft.ProcessSimple{(AsAdmin ? "/scopes/admin" : "")}/environments/{environmentName}/{(AsAdmin ? "v2" : "")}/flows?api-version=2016-11-01{(filter != null ? $"&$filter={filter}" : "")}";
85+
var flows = GraphHelper.GetResultCollection<Model.PowerPlatform.PowerAutomate.Flow>(this, Connection, flowUrl, AccessToken);
86+
8587
WriteObject(flows, true);
8688

8789
}

0 commit comments

Comments
 (0)