Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hi.
I do not come from a scripting/coding background so I've difficulties with this. How to use Powershell to refresh a dataset?
I managed to both
1. use "Try it" here https://docs.microsoft.com/en-us/rest/api/power-bi/datasets/refreshdatasetingroup
2. wrote PS script to return list of last refreshes of a given dataset:
Invoke-PowerBIRestMethod -Url "https://api.powerbi.com/v1.0/myorg/groups/{...}/datasets/{...}/refreshes" -Method Get
But how do I actually refresh a dataset? Thank you so much guys!
Solved! Go to Solution.
Ok now it's messing with us haha. How many times have you refresh the dataset today? Asking to refresh like is still count in 8 times a day limitation. If we are running the 9th, it will response 400 like now.
If you haven't refreshed 8 times today let's try adding the body (it shouldn't be that because it's not mandatory, but we don't have anything to lose)
$MailFailureNotify = @{"notifyOption"="MailOnFailure"}
Invoke-PowerBIRestMethod -Url $RefreshDSURL -Method Post
-Body $MailFailureNotify
I hope this helps,
Happy to help!
Hi. That might be because the method should be "Post" and not "Get". I usually send this example:
https://github.com/ibarrau/PowerBi-code/blob/master/PowerShell/RefreshPowerBi.ps1
But this time I think it might be that the only missing thing if you get to that line.
Regards,
Happy to help!
Oh I pasted the wrong line from my notepad 😄 Yeah POST for sure.
Also, is your avatar from Goonies II or Ice climber?
Your avatar reigns supreme!
But what I got was:
I don't know what I am missing. Well powershell skillz for sure!
That's odd. Please be sure your credentials are ok. Try no using the first lines of my code for login and just use:
Connect-PowerBIServiceAccount
That will show a pop-up of microsoft login. Let's see if that give us error.
Be sure to complete the correct ids for the URL like the code in github. You can take them from Power Bi Service URL when you are in the dataset.
Regards,
Happy to help!
Connect-PowerBIServiceAccount works fine. And the id's I've double checked from both the browser and using powershell cmdlets.
Can you show me the full picture of the error that show when you do this?
$DSIDRefresh = "XXXX-XXXX-XXXX-XXXX"
$WSIDAdmin = "XXXX-XXXX-XXXX-XXXX"
$RefreshDSURL = 'groups/' + $WSIDAdmin + '/datasets/' + $DSIDRefresh + '/refreshes'
Invoke-PowerBIRestMethod -Url $RefreshDSURL -Method Post
That url with "groups/XXXX-XXXX-XXXX-XXXX/datasets/XXXX-XXXX-XXXX-XXXX/refreshes" should work. Don't use the one in the API doc.
Please also try another method of the cmdlet like "Get-PowerBIWorkspace". Let see if there is a problem in Rest Method or permission.
Regards
Happy to help!
Get-PowerBIWorkspace works just fine.
Ok now it's messing with us haha. How many times have you refresh the dataset today? Asking to refresh like is still count in 8 times a day limitation. If we are running the 9th, it will response 400 like now.
If you haven't refreshed 8 times today let's try adding the body (it shouldn't be that because it's not mandatory, but we don't have anything to lose)
$MailFailureNotify = @{"notifyOption"="MailOnFailure"}
Invoke-PowerBIRestMethod -Url $RefreshDSURL -Method Post
-Body $MailFailureNotify
I hope this helps,
Happy to help!
Thanks for all the help, but still no success.
This should be the third update today, so no problems there. I dunnoo, I get something wrong.
I tried against another dataset and now it worked!
As a sidenote Adam here is doing the same thing but he uses body parameter. He doesn't show it though, I really don't understan what should go there?
https://youtu.be/ClmZ-8p6x9g?t=478
Good. Hope that works for you. Please accept the post as an answer if you make it work as expected so other users can find it easily.
It is a custom paint creation I made from Ice Climbers 🙂
Regards,
Happy to help!
Am I missing something like:
-ContentType "application/json" -Headers
and after "-Headers" I'd use some notation to give bearer token?
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
38 | |
26 | |
23 | |
19 | |
17 |
User | Count |
---|---|
49 | |
40 | |
24 | |
20 | |
20 |