Power BI
14 TopicsHelp In Editing Data Source Credentials in PowerShell for Power BI Embedded Dashboards in D365 CRM
Hello, We are currently migrating Power BI embedded dashboards from one Dynamics 365 CRM tenant to another. The process involves creating a new Power BI report within a workspace. Since the Dynamics 365 Solution does not support the inclusion of Power BI reports within unmanaged solutions, we have resorted to using PowerShell scripting to manage the migration. During this migration, we encountered an issue where the report IDs from the original environment remained linked when moving the Power BI embedded dashboards to the new environment. To address this, we have utilized Environment Variables to map the new report and workspace IDs appropriately. However, we are facing an issue when attempting to edit the Data Source Credentials using PowerShell scripting. Specifically, we are receiving a "Bad Request" error, as shown in the screenshot below. Here is the PowerShell code we are currently using to edit the Data Source Credentials: Connect-PowerBIServiceAccount $accesstoken = Get-PowerBIAccessToken $patchBody = '"credentialDetails": { "credentials": {"accessToken":"'+$($accesstoken)+'"}, "encryptedConnection": "Encrypted", "encryptionAlgorithm": "None", "privacyLevel": "Organizational", "useEndUserOAuth2Credentials": true }' Invoke-PowerBIRestMethod -Url "https://api.powerbi.com/v1.0/myorg/gateways/9eaed562-e9c2-46e4-91cf-276ed0947b41/datasources/f1181856-de29-4a9a-a555-a0e181cd7898" -Method Patch -Body $patchBody We would greatly appreciate any guidance or suggestions on resolving this error in the PowerShell scripting process for updating the Data Source Credentials. Thanks! Inogic Professional Services: Power Platform/Dynamics 365 CRM An expert technical extension for your techno-functional business needs Drop an email at email address removed for privacy reasons Service: https://www.inogic.com/services/ Tips and Tricks: https://www.inogic.com/blog/37Views0likes1CommentAssistance Needed with OneDrive and Office 365 Activity PowerShell Scripts
Dear All, I am using the scripts below to retrieve OneDrive and Office 365 activity details for my tenant. However, in the "User Principal Name" field, I am getting an ID instead of the email address. This issue started after September 18; prior to that, it was working fine and showing the email addresses as expected. I run these scripts daily and generate a Power BI report based on the output. Scripts Used Get User OneDrive Activity: Invoke-GraphApiRequest -uri "https://graph.microsoft.com/v1.0/reports/getOneDriveActivityUserDetail(date=$yesterdaydate)" -FileName "OneDrive\ODUserDailyActivity\OneDriveUserDailyActivity" -Verbose:$VerbosePreference Invoke-GraphApiRequest -uri "https://graph.microsoft.com/v1.0/reports/getOneDriveUsageAccountDetail(date=$yesterdaydate)" -FileName "OneDrive\ODUsageDailyReport\OneDriveUsageDailyReport" -Verbose:$VerbosePreference Here is an example of the output I’m receiving: Report Refresh Date,User Principal Name,Is Deleted,Deleted Date,Last Activity Date,Viewed Or Edited File Count,Synced File Count,Shared Internally File Count,Shared Externally File Count,Assigned Products,Report Period 2024-11-22,830E1CDE8B16F21C80B207D213852737,False,,2024-11-22,1,0,0,0,MICROSOFT COPILOT STUDIO VIRAL TRIAL+MICROSOFT 365 E5+MICROSOFT COPILOT STUDIO USER LICENSE+MICROSOFT POWER AUTOMATE FREE+MICROSOFT INTUNE SUITE+MICROSOFT FABRIC (FREE)+MICROSOFT DEFENDER VULNERABILITY MANAGEMENT ADD-ON+DYNAMICS 365 CUSTOMER VOICE TRIAL+PLANNER AND PROJECT PLAN 3+POWER APPS PREMIUM+MICROSOFT POWER APPS FOR DEVELOPER,1 This is just one example, but I am seeing similar results for most of these scripts. Could you please help me resolve this issue? Thank you in advance!355Views0likes0CommentsFabric API: Update user scopes
Context: The token I generated was retrieved by logging in with 'Login-PowerBI', followed by "Get-PowerBiAccessToken -asstring" inside of Powershell. This token was then copied and used inside of postman for the authorization. I didn't use any extra parameters. Since the current usage of a Service Principal is quite limited for the Fabric API, we're opting to use the personal bearer token. Scenario: At our company we're trying to experiment a bit with the MS Fabric API (https://api.fabric.microsoft.com). With the service principal token, we've been able to use the API to list the workspaces, items, ... basically most standard get calls you could imagine. But, it doesn't support creating items yet via the service principal. So, we had to switch to the usage of a personal user token. We are able to create workspaces via my individual token, but I'm unable to create individual items inside of a workspace. This is due to the fact that I don't have any individual item level scopes assigned to me for now. My current scopes are: "App.Read.All Capacity.Read.All Capacity.ReadWrite.All Content.Create Dashboard.Read.All Dashboard.ReadWrite.All Dataflow.Read.All Dataflow.ReadWrite.All Dataset.Read.All Dataset.ReadWrite.All Gateway.Read.All Gateway.ReadWrite.All Pipeline.Deploy Pipeline.Read.All Pipeline.ReadWrite.All Report.Read.All Report.ReadWrite.All StorageAccount.Read.All StorageAccount.ReadWrite.All Tenant.Read.All Tenant.ReadWrite.All UserState.ReadWrite.All Workspace.Read.All Workspace.ReadWrite.All" As you can see, it's quite normal that I'm only able to create a Workspace. But I want to be able to assign e.g. "Notebook.ReadWrite.All" to my user. How do I do this for an individual user? I'm trying to automate as much as possible using Powershell scripts, but the current scopes are quite limited. Goal: Using a personal bearer token (not generated through a service principal) to create a notebook item. Endpoint: https://learn.microsoft.com/en-us/rest/api/fabric/core/items/create-item?tabs=HTTP Question: Is it possible to do this without the usage of a service principal? I know you can use the copy(PowerBIAccessToken) inside of the dev-tools in your browser, but I want to do it more automatically. Hopefully this is the right section to ask such things, and thank you in advance for your help!333Views0likes0CommentsAPI to change the name of a dataflow
Hello, I would like to be able to change the name of a dataflow using this API: https://learn.microsoft.com/en-us/rest/api/power-bi/dataflows/update-dataflow Here is my code: $body=@{ name = "DTF TEST Pipeline 1.0.1" } Invoke-PowerBIRestMethod -Url "https://api.powerbi.com/v1.0/myorg/groups/8569358a-549c-466a-894c-de113f5c4fb1/dataflows/8774dad3-3f17-4444-b73b-b82cea0812b6" -Method Patch -Body $body However when I run the command I get this error message: Invoke-PowerBIRestMethod : Une ou plusieurs erreurs se sont produites. Au caractère Ligne:12 : 1 + Invoke-PowerBIRestMethod -Url "https://api.powerbi.com/v1.0/myorg/gro ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : WriteError: (Microsoft.Power...werBIRestMethod:InvokePowerBIRestMethod) [Invoke-PowerBIRestMethod], AggregateException + FullyQualifiedErrorId : Une ou plusieurs erreurs se sont produites.,Microsoft.PowerBI.Commands.Profile.InvokePowerBIRestMethod Invoke-PowerBIRestMethod : Encountered errors when invoking the command: { "code": "BadRequest", "message": "Bad Request", "details": [ { "message": "Unexpected character encountered while parsing value: S. Path '', line 0, position 0.", "target": "dataflowUpdateInformation" } ] } Au caractère Ligne:12 : 1 + Invoke-PowerBIRestMethod -Url "https://api.powerbi.com/v1.0/myorg/gro ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : WriteError: (Microsoft.Power...werBIRestMethod:InvokePowerBIRestMethod) [Invoke-PowerBIRestMethod], Exception + FullyQualifiedErrorId : Encountered errors when invoking the command: { "code": "BadRequest", "message": "Bad Request", "details": [ { "message": "Unexpected character encountered while parsing value: S. Path '', line 0, position 0.", "target": "dataflowUpdateInformation" } ] },Microsoft.PowerBI.Commands.Profile.InvokePowerBIRestMethod799Views0likes1Comment"get-PowerBiWorkspace" giving error like 'incompatible with the array'
Hi, "Get-PowerBiWorkspace " is giving error like below. I tried to execute in VS-Code, ISE and Powershell -Noprofile, but no luck. Please help me to resolve this. get-PowerBiworkspace : Attempted to access an element as a type incompatible with the array. At line:1 char:1 + get-PowerBiworkspace + ~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : WriteError: (Microsoft.Power...owerBIWorkspace:GetPowerBIWorkspace) [Get-PowerBIWorkspace], ArrayTypeMismatchException + FullyQualifiedErrorId : Attempted to access an element as a type incompatible with the array.,Microsoft.PowerBI.Commands.Workspaces.GetPowerBIWorkspace I am using PowerShell 5.1 .Below is list of modules are present in my machine. Newtonsoft module:: MDStreamVersion : 131072 FullyQualifiedName : C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\2.1.2\PreloadAssemblies\Newtonsoft.Json.12.0.3.dll ModuleVersionId : 2676a2da-6edc-420e-890e-d28aa4572ee5 MetadataToken : 1 ScopeName : Newtonsoft.Json.dll Name : Newtonsoft.Json.12.0.3.dll Assembly : Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed CustomAttributes : {} ModuleHandle : System.ModuleHandle MicrosoftPowerBIMgmt module:: I have uninstalled MicrosoftPowerBIMgmt and installed it again.5.2KViews0likes1CommentHelp with Power BI REST API output
I have the following script that is using Invoke-PowerBIRestMethod. I have a couple of issues I need to help solving. 1. You can see I'm trying to convert the output of the API to a table or some kind of useable/readable format. Getting it to a csv would be fine but none of the output is useful or formatted. 2. The output does not include the Original GUIDs that I am looping through. Is there a way to get those added to the final output. Somerhing like GUID - (The actual report id uses in the API url parameter) emailaddress owner displayname identifier userType Login-PowerBIServiceAccount $ReportIDs = $(Get-PowerBIReport -Scope Organization).ID $ReportIDs $endreport = @() ForEach ($id in $ReportIDs){ $endreport += --Invoke-PowerBIRestMethod -Url "https://api.powerbi.com/v1.0/myorg/admin/reports/$id/users" ----Method Get|ConvertFrom-String|Format-List #the convert and format-tables don't really help when I try to export them. } $endreport1.8KViews0likes1Commentset alias for Power BI
My Windows 10 Pro has Anaconda Powershell Prompt, and its $PSVersionTable is: Name Value PSVersion 5.1.19041.1682 PSEdition Desktop PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…} BuildVersion 10.0.19041.1682 CLRVersion 4.0.30319.42000 WSManStackVersion 3.0 PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1 I have to “run as Administrator” in order to run commands in Anaconda Powershell Prompt. I’m unfamiliar with its commands though, except to activate a conda environment. After I’ve activated a conda environment (that’s customized for Microsoft Power BI Desktop), I can start the program at C:\Program Files\WindowsApps\Microsoft.MicrosoftPowerBIDesktop_2.105.664.0_x64__8wekyb3d8bbwe\bin\PBIDesktop.exe . Since that path is so long, I want to create a program alias. I followed the instructions to add a new key in Registry Editor. But why do I get the error: start : This command cannot be run due to the error: The system cannot find the file specified. At line:1 char:1 start PBIDesktop + CategoryInfo : InvalidOperation: (:) [Start-Process], InvalidOperationException + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand P.S. if I click on the shortcut icon for Power BI after activating the conda environment, Power BI will still show a Python script error. Apparently, it still needs to be started from the conda environment.2KViews0likes5CommentsPowershell downloads the login webpage html instead of a file
Hello I have a website.com where I login via a form and it has a second step authentication too. After I fully login, a session starts and I can type a specific url in the address bar of IE/Edge and it will trigger a download of an xlsx file. I want to get these files every 30 min and I was checking Powershell as other options are limited. However, using Invoke-WebRequest results in downloading the login webpage html instead of the file. Any idea? Also, do you know any other method to get these files regularly so that the session renews? It is impossible to automate the login as it requires a mobile phone. An API is paid so again it's not an option. Also, tried a Data Connection in Excel but it does download the same html. Thanks!3KViews0likes1CommentError while using the Export API to export Paginated report located on PBI Service into a .xlsx file
Hi folks, I am trying to run this script to export paginated report into an excel file using PowerShell but I am getting an error, Could anyone please help me? Things which ran successfully using PowerShell : Logging into PBI Service , Retrieving Workspace and Report ID $reportId = "7abc73b4-0bad-4edb-8f52-xxxxxxxxxxxx" $groupId = "04a7c8b4-9c13-4838-b812- xxxxxxxxxxxx " $endpoint = "https://api.powerbi.com/v1.0/myorg/reports/$reportId/ExportTo" $endpoint = "https://api.powerbi.com/v1.0/myorg/groups/$groupId/reports/$reportId/ExportTo" $body = @" { "format": “XLSX" } "@ $headers = Get-PowerBIAccessToken $headers.Add("Content-type", "application/json") $response = Invoke-RestMethod -Headers $headers -Uri $endpoint -Body $body -Method 'Post' $response Error:861Views0likes0Comments